Zelda Classic Coverage Report


Directory: src/
File: src/guys.cpp
Date: 2023-02-27 01:46:08
Exec Total Coverage
Lines: 8490 12514 67.8%
Functions: 323 425 76.0%
Branches: 6603 14514 45.5%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // guys.cc
6 //
7 // "Guys" code (and other related stuff) for zelda.cc
8 //
9 //--------------------------------------------------------
10
11 #include "precompiled.h" //always first
12
13 #include <string.h>
14 #include <stdio.h>
15 #include "base/zc_alleg.h"
16 #include "guys.h"
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 #include "zelda.h"
18 #include "base/zsys.h"
19 #include "maps.h"
20 #include "hero.h"
21 #include "subscr.h"
22 #include "ffscript.h"
23 #include "gamedata.h"
24 #include "defdata.h"
25 #include "zscriptversion.h"
26 #include "particles.h"
27 #include "base/zc_math.h"
28 #include "slopes.h"
29 extern particle_list particles;
30
31 extern FFScript FFCore;
32 extern word item_doscript[256];
33 extern refInfo itemScriptData[256];
34 extern int32_t item_stack[256][MAX_SCRIPT_REGISTERS];
35 extern ZModule zcm;
36 extern HeroClass Hero;
37 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
38 extern zinitdata zinit;
39
40 int32_t repaircharge=0;
41 bool adjustmagic=false;
42 bool learnslash=false;
43 int32_t wallm_load_clk=0;
44 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
45 int32_t vhead=0;
46 int32_t guycarryingitem=0;
47
48 char *guy_string[eMAXGUYS];
49
50 void never_return(int32_t index);
51 void playLevelMusic();
52
53 // If an enemy is this far out of the playing field, just remove it.
54 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
55 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
56 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
57 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
58
59 484017 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
60 {
61 484017 int32_t c = coord.getInt();
62
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 483750 times.
484017 if(nearest_half)
63 {
64
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 483750 times.
483750 if (c < 0)
65 c -= val / 2;
66 483750 else c += (val/2);
67 483750 }
68 484017 c -= c % val;
69 484017 coord = c;
70 484017 }
71
72 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
73 {
74 return
75 (
76 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
77 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
78 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
79 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
80 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
81 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
82 );
83 }
84
85 namespace
86 {
87 int32_t trapConstantHorizontalID;
88 int32_t trapConstantVerticalID;
89 int32_t trapLOSHorizontalID;
90 int32_t trapLOSVerticalID;
91 int32_t trapLOS4WayID;
92
93 int32_t cornerTrapID;
94 int32_t centerTrapID;
95
96 int32_t rockID;
97 int32_t zoraID;
98 int32_t statueID;
99 }
100
101 94 void identifyCFEnemies()
102 {
103 94 trapConstantHorizontalID=-1;
104 94 trapConstantVerticalID=-1;
105 94 trapLOSHorizontalID=-1;
106 94 trapLOSVerticalID=-1;
107 94 trapLOS4WayID=-1;
108 94 cornerTrapID=-1;
109 94 centerTrapID=-1;
110 94 rockID=-1;
111 94 zoraID=-1;
112 94 statueID=-1;
113
114
2/2
✓ Branch 0 taken 48128 times.
✓ Branch 1 taken 94 times.
48222 for(int32_t i=0; i<eMAXGUYS; i++)
115 {
116
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 48035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
48128 if((guysbuf[i].flags2&cmbflag_trph) && trapLOSHorizontalID==-1)
117 93 trapLOSHorizontalID=i;
118
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 48031 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&cmbflag_trpv) && trapLOSVerticalID==-1)
119 94 trapLOSVerticalID=i;
120
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 48034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&cmbflag_trp4) && trapLOS4WayID==-1)
121 94 trapLOS4WayID=i;
122
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 48034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&cmbflag_trplr) && trapConstantHorizontalID==-1)
123 94 trapConstantHorizontalID=i;
124
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 48034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&cmbflag_trpud) && trapConstantVerticalID==-1)
125 94 trapConstantVerticalID=i;
126
127
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 48034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&eneflag_trap) && cornerTrapID==-1)
128 94 cornerTrapID=i;
129
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 48034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&eneflag_trp2) && centerTrapID==-1)
130 94 centerTrapID=i;
131
132
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 48034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&eneflag_rock) && rockID==-1)
133 94 rockID=i;
134
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 48034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&eneflag_zora) && zoraID==-1)
135 94 zoraID=i;
136
137
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 48031 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2 & eneflag_fire) && statueID==-1)
138 94 statueID=i;
139 48128 }
140 94 }
141
142 25 int32_t random_layer_enemy()
143 {
144 25 int32_t cnt=count_layer_enemies();
145
146
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(cnt==0)
147 {
148 return eNONE;
149 }
150
151 25 int32_t ret=zc_oldrand()%cnt;
152 25 cnt=0;
153
154
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 for(int32_t i=0; i<6; ++i)
155 {
156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(tmpscr->layermap[i]!=0)
157 {
158 25 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
159
160
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 for(int32_t j=0; j<10; ++j)
161 {
162
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
163 {
164
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 102 times.
127 if(cnt==ret)
165 {
166 25 return layerscreen->enemy[j];
167 }
168
169 102 ++cnt;
170 102 }
171 102 }
172 }
173 }
174
175 return eNONE;
176 25 }
177
178 39 int32_t count_layer_enemies()
179 {
180 39 int32_t cnt=0;
181
182
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 39 times.
273 for(int32_t i=0; i<6; ++i)
183 {
184
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 39 times.
234 if(tmpscr->layermap[i]!=0)
185 {
186 39 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
187
188
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 39 times.
429 for(int32_t j=0; j<10; ++j)
189 {
190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
390 if(layerscreen->enemy[j]!=0)
191 {
192 390 ++cnt;
193 390 }
194 390 }
195 39 }
196 234 }
197
198 39 return cnt;
199 }
200
201 113541 int32_t hero_on_wall()
202 {
203 113541 zfix lx = Hero.getX();
204 113541 zfix ly = Hero.getY();
205
206
207 //zprint2("hero_on_wall x is: %d\n", lx);
208 //zprint2("hero_on_wall y is: %d\n", ly);
209
210
4/4
✓ Branch 0 taken 106579 times.
✓ Branch 1 taken 6962 times.
✓ Branch 2 taken 2931 times.
✓ Branch 3 taken 103648 times.
113541 if(lx>=48 && lx<=192)
211 {
212
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 103523 times.
103648 if(ly==32) return up+1;
213
214
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 103421 times.
103523 if(ly==128) return down+1;
215 103421 }
216
217
4/4
✓ Branch 0 taken 105191 times.
✓ Branch 1 taken 8123 times.
✓ Branch 2 taken 9150 times.
✓ Branch 3 taken 96041 times.
113314 if(ly>=48 && ly<=112)
218 {
219
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 95938 times.
96041 if(lx==32) return left+1;
220
221
2/2
✓ Branch 0 taken 95891 times.
✓ Branch 1 taken 47 times.
95938 if(lx==208) return right+1;
222 95891 }
223
224 113164 return 0;
225 113541 }
226
227 655550 bool tooclose(int32_t x,int32_t y,int32_t d)
228 {
229
2/2
✓ Branch 0 taken 484096 times.
✓ Branch 1 taken 171454 times.
655550 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
230 }
231
232 1588819 bool enemy::overpit(enemy *e)
233 {
234
2/2
✓ Branch 0 taken 1585651 times.
✓ Branch 1 taken 20086672 times.
21672323 for ( int32_t q = 0; q < hxsz; ++q )
235 {
236
2/2
✓ Branch 0 taken 194455660 times.
✓ Branch 1 taken 20083504 times.
214539164 for ( int32_t q = 0; q < hysz; ++q )
237 {
238 //check every pixel of the hitbox
239
2/2
✓ Branch 0 taken 3168 times.
✓ Branch 1 taken 194452492 times.
194455660 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
240 {
241 //if the hitbox is over a pit, we can't land
242 3168 return true;
243 }
244 194452492 }
245 20083504 }
246 1585651 return false;
247 1588819 }
248
249 3194659 bool enemy::shadow_overpit(enemy *e)
250 {
251
2/2
✓ Branch 0 taken 3190807 times.
✓ Branch 1 taken 48911384 times.
52102191 for ( int32_t q = 0; q < hxsz; ++q )
252 {
253
2/2
✓ Branch 0 taken 738706875 times.
✓ Branch 1 taken 48907532 times.
787614407 for ( int32_t q = 0; q < hysz; ++q )
254 {
255 //check every pixel of the hitbox
256
2/2
✓ Branch 0 taken 3852 times.
✓ Branch 1 taken 738703023 times.
738706875 if ( ispitfall(x+q+hxofs, y+q+hyofs+hysz-2) )
257 {
258 //if the hitbox is over a pit, we can't land
259 3852 return true;
260 }
261 738703023 }
262 48907532 }
263 3190807 return false;
264 3194659 }
265
266 // Returns true iff a combo type or flag precludes enemy movement.
267 2724844 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
268 {
269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2724844 times.
2724844 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
270 2724844 int32_t c = COMBOTYPE(dx,dy);
271
4/4
✓ Branch 0 taken 1770128 times.
✓ Branch 1 taken 954716 times.
✓ Branch 2 taken 288848 times.
✓ Branch 3 taken 665868 times.
3679560 bool pit_blocks = (!(moveflags & (FLAG_CAN_PITWALK|FLAG_ONLY_PITWALK)) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
272
3/6
✓ Branch 0 taken 940916 times.
✓ Branch 1 taken 1783928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 940916 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2724844 bool water_blocks = (!(moveflags & (FLAG_CAN_WATERWALK|FLAG_ONLY_WATERWALK|FLAG_ONLY_SHALLOW_WATERWALK)) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB) && get_bit(quest_rules,qr_DROWN));
273
4/6
✓ Branch 0 taken 976369 times.
✓ Branch 1 taken 1748475 times.
✓ Branch 2 taken 976369 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 976369 times.
✗ Branch 5 not taken.
5450169 return c==cPIT || c==cPITB || c==cPITC ||
274
4/6
✓ Branch 0 taken 976369 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 976369 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 875797 times.
✓ Branch 5 taken 100572 times.
976369 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
275 // Block enemies type and block enemies flags
276
2/2
✓ Branch 0 taken 975050 times.
✓ Branch 1 taken 874478 times.
100572 combo_class_buf[c].block_enemies&1 ||
277
3/4
✓ Branch 0 taken 975048 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 975048 times.
✗ Branch 3 not taken.
975050 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
278
4/4
✓ Branch 0 taken 974829 times.
✓ Branch 1 taken 219 times.
✓ Branch 2 taken 974819 times.
✓ Branch 3 taken 10 times.
975048 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
279 // Check for ladder-only combos which aren't dried water
280
3/4
✓ Branch 0 taken 639 times.
✓ Branch 1 taken 974180 times.
✓ Branch 2 taken 639 times.
✗ Branch 3 not taken.
1949638 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
281 // Check for drownable water
282
4/4
✓ Branch 0 taken 123963 times.
✓ Branch 1 taken 850856 times.
✓ Branch 2 taken 14620 times.
✓ Branch 3 taken 109343 times.
974819 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
283 976850 }
284
285 // Returns true iff enemy is floating and blocked by a combo type or flag.
286 3539853 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
287 {
288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3539853 times.
3539853 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
289
4/4
✓ Branch 0 taken 2764890 times.
✓ Branch 1 taken 774963 times.
✓ Branch 2 taken 546911 times.
✓ Branch 3 taken 228052 times.
4314816 bool pit_blocks = (!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
290
3/4
✓ Branch 0 taken 2774894 times.
✓ Branch 1 taken 764959 times.
✓ Branch 2 taken 764959 times.
✗ Branch 3 not taken.
4304812 bool water_blocks = (!(moveflags & FLAG_CAN_WATERWALK) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB));
291
2/2
✓ Branch 0 taken 412903 times.
✓ Branch 1 taken 3126950 times.
6666803 return ((special==spw_floater)&&
292
2/2
✓ Branch 0 taken 3120839 times.
✓ Branch 1 taken 6111 times.
3126950 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
293
1/2
✓ Branch 0 taken 3120839 times.
✗ Branch 1 not taken.
3120839 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
294
1/2
✓ Branch 0 taken 3120839 times.
✗ Branch 1 not taken.
3120839 (MAPFLAG(dx,dy)==mfNOENEMY)||
295
1/2
✓ Branch 0 taken 3120839 times.
✗ Branch 1 not taken.
3120839 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
296
4/4
✓ Branch 0 taken 411425 times.
✓ Branch 1 taken 2709414 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 411218 times.
6241471 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
297
2/2
✓ Branch 0 taken 2702951 times.
✓ Branch 1 taken 417681 times.
3120632 (pit_blocks && ispitfall(dx,dy))));
298 3539853 }
299 // Returns true iff a combo type or flag precludes enemy movement.
300 229849 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
301 {
302 229849 int32_t c = COMBOTYPE(dx,dy);
303 229849 bool pit_blocks = !(gd.moveflags & FLAG_CAN_PITWALK);
304
2/2
✓ Branch 0 taken 27325 times.
✓ Branch 1 taken 202524 times.
229849 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK) && get_bit(quest_rules,qr_DROWN);
305
3/6
✓ Branch 0 taken 229849 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229849 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 229849 times.
✗ Branch 5 not taken.
871312 return c==cPIT || c==cPITB || c==cPITC ||
306
4/6
✓ Branch 0 taken 229849 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229849 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 205814 times.
✓ Branch 5 taken 24035 times.
229849 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
307 // Block enemies type and block enemies flags
308
2/2
✓ Branch 0 taken 229842 times.
✓ Branch 1 taken 205807 times.
24035 combo_class_buf[c].block_enemies&1 ||
309
3/4
✓ Branch 0 taken 229723 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 229723 times.
✗ Branch 3 not taken.
229842 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
310
3/4
✓ Branch 0 taken 226255 times.
✓ Branch 1 taken 3468 times.
✓ Branch 2 taken 226255 times.
✗ Branch 3 not taken.
229723 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
311 // Check for ladder-only combos which aren't dried water
312
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 226220 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
452510 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
313 // Check for drownable water
314
4/4
✓ Branch 0 taken 33520 times.
✓ Branch 1 taken 192735 times.
✓ Branch 2 taken 25138 times.
✓ Branch 3 taken 8382 times.
226255 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
315 }
316
317 // Returns true iff enemy is floating and blocked by a combo type or flag.
318 113422 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
319 {
320
2/2
✓ Branch 0 taken 112869 times.
✓ Branch 1 taken 553 times.
113422 bool pit_blocks = (!(gd.moveflags & FLAG_CAN_PITWALK) && !(gd.moveflags & FLAG_CAN_PITFALL));
321 113422 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK);
322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113422 times.
226844 return ((special==spw_floater)&&
323
1/2
✓ Branch 0 taken 113422 times.
✗ Branch 1 not taken.
113422 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
324
1/2
✓ Branch 0 taken 113422 times.
✗ Branch 1 not taken.
113422 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
325
1/2
✓ Branch 0 taken 113422 times.
✗ Branch 1 not taken.
113422 (MAPFLAG(dx,dy)==mfNOENEMY)||
326
1/2
✓ Branch 0 taken 113422 times.
✗ Branch 1 not taken.
113422 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
327
4/4
✓ Branch 0 taken 553 times.
✓ Branch 1 taken 112869 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 544 times.
226835 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
328
2/2
✓ Branch 0 taken 112869 times.
✓ Branch 1 taken 544 times.
113413 (pit_blocks && ispitfall(dx,dy))));
329 }
330
331 /**********************************/
332 /******* Enemy Base Class *******/
333 /**********************************/
334
335 /* ROM data flags
336
337 */
338
339 eFire::eFire(eFire const & other, bool new_script_uid, bool clear_parent_script_UID):
340 //Struct Element Type Purpose
341 //sprite(other),
342 enemy(other),
343 clk4(other.clk4),
344 shield(other.shield)
345
346 {
347
348 //arrays
349
350 if(other.scrmem)
351 {
352 alloc_scriptmem();
353 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
354
355 scrmem->scriptData = other.scrmem->scriptData;
356 }
357 else scrmem = NULL;
358 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
359 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
360
361 for(int32_t i=0; i<edefLAST255; i++)
362 defense[i]=other.defense[i];
363 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
364 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
365
366 if(new_script_uid)
367 {
368 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
369 }
370 if(clear_parent_script_UID)
371 {
372 parent_script_UID = 0;
373 }
374 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
375 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
376
377 for ( int32_t q = 0; q < 8; q++ )
378 {
379 initD[q] = other.initD[q];
380 weap_initiald[q] = other.weap_initiald[q];
381 }
382 for ( int32_t q = 0; q < 2; q++ )
383 {
384 initA[q] = other.initA[q];
385 weap_initiala[q] = other.weap_initiala[q];
386 }
387 }
388
389 eOther::eOther(eOther const & other, bool new_script_uid, bool clear_parent_script_UID):
390 //Struct Element Type Purpose
391 //sprite(other),
392 enemy(other),
393 clk4(other.clk4),
394 shield(other.shield)
395
396 {
397
398 //arrays
399
400 if(other.scrmem)
401 {
402 alloc_scriptmem();
403 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
404
405 scrmem->scriptData = other.scrmem->scriptData;
406 }
407 else scrmem = NULL;
408 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
409 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
410
411 for(int32_t i=0; i<edefLAST255; i++)
412 defense[i]=other.defense[i];
413 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
414 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
415
416 if(new_script_uid)
417 {
418 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
419 }
420 if(clear_parent_script_UID)
421 {
422 parent_script_UID = 0;
423 }
424 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
425 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
426
427 for ( int32_t q = 0; q < 8; q++ )
428 {
429 initD[q] = other.initD[q];
430 weap_initiald[q] = other.weap_initiald[q];
431 }
432 for ( int32_t q = 0; q < 2; q++ )
433 {
434 initA[q] = other.initA[q];
435 weap_initiala[q] = other.weap_initiala[q];
436 }
437 }
438
439
440
441
442 eScript::eScript(eScript const & other, bool new_script_uid, bool clear_parent_script_UID):
443 //Struct Element Type Purpose
444 //sprite(other),
445 enemy(other),
446 clk4(other.clk4),
447 shield(other.shield)
448
449 {
450
451 //arrays
452
453 if(other.scrmem)
454 {
455 alloc_scriptmem();
456 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
457
458 scrmem->scriptData = other.scrmem->scriptData;
459 }
460 else scrmem = NULL;
461 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
462 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
463
464 for(int32_t i=0; i<edefLAST255; i++)
465 defense[i]=other.defense[i];
466 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
467 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
468
469 if(new_script_uid)
470 {
471 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
472 }
473 if(clear_parent_script_UID)
474 {
475 parent_script_UID = 0;
476 }
477 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
478 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
479
480 for ( int32_t q = 0; q < 8; q++ )
481 {
482 initD[q] = other.initD[q];
483 weap_initiald[q] = other.weap_initiald[q];
484 }
485 for ( int32_t q = 0; q < 2; q++ )
486 {
487 initA[q] = other.initA[q];
488 weap_initiala[q] = other.weap_initiala[q];
489 }
490 }
491
492 eFriendly::eFriendly(eFriendly const & other, bool new_script_uid, bool clear_parent_script_UID):
493 //Struct Element Type Purpose
494 //sprite(other),
495 enemy(other),
496 clk4(other.clk4),
497 shield(other.shield)
498
499 {
500
501 //arrays
502
503 if(other.scrmem)
504 {
505 alloc_scriptmem();
506 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
507
508 scrmem->scriptData = other.scrmem->scriptData;
509 }
510 else scrmem = NULL;
511 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
512 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
513
514 for(int32_t i=0; i<edefLAST255; i++)
515 defense[i]=other.defense[i];
516 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
517 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
518
519 if(new_script_uid)
520 {
521 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
522 }
523 if(clear_parent_script_UID)
524 {
525 parent_script_UID = 0;
526 }
527 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
528 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
529
530 for ( int32_t q = 0; q < 8; q++ )
531 {
532 initD[q] = other.initD[q];
533 weap_initiald[q] = other.weap_initiald[q];
534 }
535 for ( int32_t q = 0; q < 2; q++ )
536 {
537 initA[q] = other.initA[q];
538 weap_initiala[q] = other.weap_initiala[q];
539 }
540 }
541
542 eGhini::eGhini(eGhini const & other, bool new_script_uid, bool clear_parent_script_UID):
543 //Struct Element Type Purpose
544 //sprite(other),
545 enemy(other),
546 clk4(other.clk4),
547 ox(other.ox),
548 oy(other.oy),
549 c(other.c)
550
551 {
552
553 //arrays
554
555 if(other.scrmem)
556 {
557 alloc_scriptmem();
558 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
559
560 scrmem->scriptData = other.scrmem->scriptData;
561 }
562 else scrmem = NULL;
563 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
564 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
565
566 for(int32_t i=0; i<edefLAST255; i++)
567 defense[i]=other.defense[i];
568 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
569 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
570
571 if(new_script_uid)
572 {
573 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
574 }
575 if(clear_parent_script_UID)
576 {
577 parent_script_UID = 0;
578 }
579 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
580 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
581
582 for ( int32_t q = 0; q < 8; q++ )
583 {
584 initD[q] = other.initD[q];
585 weap_initiald[q] = other.weap_initiald[q];
586 }
587 for ( int32_t q = 0; q < 2; q++ )
588 {
589 initA[q] = other.initA[q];
590 weap_initiala[q] = other.weap_initiala[q];
591 }
592 }
593
594 eTektite::eTektite(eTektite const & other, bool new_script_uid, bool clear_parent_script_UID):
595 //Struct Element Type Purpose
596 //sprite(other),
597 enemy(other),
598 old_y(other.old_y),
599 clk2start(other.clk2start),
600 cstart(other.cstart),
601 c(other.c)
602
603 {
604
605 //arrays
606
607 if(other.scrmem)
608 {
609 alloc_scriptmem();
610 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
611
612 scrmem->scriptData = other.scrmem->scriptData;
613 }
614 else scrmem = NULL;
615 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
616 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
617
618 for(int32_t i=0; i<edefLAST255; i++)
619 defense[i]=other.defense[i];
620 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
621 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
622
623 if(new_script_uid)
624 {
625 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
626 }
627 if(clear_parent_script_UID)
628 {
629 parent_script_UID = 0;
630 }
631 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
632 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
633
634 for ( int32_t q = 0; q < 8; q++ )
635 {
636 initD[q] = other.initD[q];
637 weap_initiald[q] = other.weap_initiald[q];
638 }
639 for ( int32_t q = 0; q < 2; q++ )
640 {
641 initA[q] = other.initA[q];
642 weap_initiala[q] = other.weap_initiala[q];
643 }
644 }
645
646 eItemFairy::eItemFairy(eItemFairy const & other, bool new_script_uid, bool clear_parent_script_UID):
647 //Struct Element Type Purpose
648 //sprite(other),
649 enemy(other)
650 {
651
652 //arrays
653
654 if(other.scrmem)
655 {
656 alloc_scriptmem();
657 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
658
659 scrmem->scriptData = other.scrmem->scriptData;
660 }
661 else scrmem = NULL;
662 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
663 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
664
665 for(int32_t i=0; i<edefLAST255; i++)
666 defense[i]=other.defense[i];
667 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
668 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
669
670 if(new_script_uid)
671 {
672 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
673 }
674 if(clear_parent_script_UID)
675 {
676 parent_script_UID = 0;
677 }
678 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
679 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
680
681 for ( int32_t q = 0; q < 8; q++ )
682 {
683 initD[q] = other.initD[q];
684 weap_initiald[q] = other.weap_initiald[q];
685 }
686 for ( int32_t q = 0; q < 2; q++ )
687 {
688 initA[q] = other.initA[q];
689 weap_initiala[q] = other.weap_initiala[q];
690 }
691 }
692
693 ePeahat::ePeahat(ePeahat const & other, bool new_script_uid, bool clear_parent_script_UID):
694 //Struct Element Type Purpose
695 //sprite(other),
696 enemy(other),
697 ox(other.ox),
698 oy(other.oy),
699 c(other.c)
700 {
701
702 //arrays
703
704 if(other.scrmem)
705 {
706 alloc_scriptmem();
707 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
708
709 scrmem->scriptData = other.scrmem->scriptData;
710 }
711 else scrmem = NULL;
712 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
713 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
714
715 for(int32_t i=0; i<edefLAST255; i++)
716 defense[i]=other.defense[i];
717 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
718 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
719
720 if(new_script_uid)
721 {
722 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
723 }
724 if(clear_parent_script_UID)
725 {
726 parent_script_UID = 0;
727 }
728 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
729 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
730
731 for ( int32_t q = 0; q < 8; q++ )
732 {
733 initD[q] = other.initD[q];
734 weap_initiald[q] = other.weap_initiald[q];
735 }
736 for ( int32_t q = 0; q < 2; q++ )
737 {
738 initA[q] = other.initA[q];
739 weap_initiala[q] = other.weap_initiala[q];
740 }
741 }
742
743 eLeever::eLeever(eLeever const & other, bool new_script_uid, bool clear_parent_script_UID):
744 //Struct Element Type Purpose
745 //sprite(other),
746 enemy(other),
747 temprule(other.temprule)
748 {
749
750 //arrays
751
752 if(other.scrmem)
753 {
754 alloc_scriptmem();
755 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
756
757 scrmem->scriptData = other.scrmem->scriptData;
758 }
759 else scrmem = NULL;
760 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
761 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
762
763 for(int32_t i=0; i<edefLAST255; i++)
764 defense[i]=other.defense[i];
765 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
766 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
767
768 if(new_script_uid)
769 {
770 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
771 }
772 if(clear_parent_script_UID)
773 {
774 parent_script_UID = 0;
775 }
776 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
777 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
778
779 for ( int32_t q = 0; q < 8; q++ )
780 {
781 initD[q] = other.initD[q];
782 weap_initiald[q] = other.weap_initiald[q];
783 }
784 for ( int32_t q = 0; q < 2; q++ )
785 {
786 initA[q] = other.initA[q];
787 weap_initiala[q] = other.weap_initiala[q];
788 }
789 }
790
791 eWallM::eWallM(eWallM const & other, bool new_script_uid, bool clear_parent_script_UID):
792 //Struct Element Type Purpose
793 //sprite(other),
794 enemy(other)
795 {
796
797 //arrays
798
799 if(other.scrmem)
800 {
801 alloc_scriptmem();
802 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
803
804 scrmem->scriptData = other.scrmem->scriptData;
805 }
806 else scrmem = NULL;
807 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
808 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
809
810 for(int32_t i=0; i<edefLAST255; i++)
811 defense[i]=other.defense[i];
812 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
813 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
814
815 if(new_script_uid)
816 {
817 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
818 }
819 if(clear_parent_script_UID)
820 {
821 parent_script_UID = 0;
822 }
823 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
824 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
825
826 for ( int32_t q = 0; q < 8; q++ )
827 {
828 initD[q] = other.initD[q];
829 weap_initiald[q] = other.weap_initiald[q];
830 }
831 for ( int32_t q = 0; q < 2; q++ )
832 {
833 initA[q] = other.initA[q];
834 weap_initiala[q] = other.weap_initiala[q];
835 }
836 }
837
838 eStalfos::eStalfos(eStalfos const & other, bool new_script_uid, bool clear_parent_script_UID):
839 //Struct Element Type Purpose
840 //sprite(other),
841 enemy(other),
842 clk4(other.clk4),
843 clk5(other.clk5),
844 fired(other.fired),
845 shield(other.shield),
846 dashing(other.dashing),
847 multishot(other.multishot),
848 fy(other.fy),
849 shadowdistance(other.shadowdistance)
850 {
851
852 //arrays
853
854 if(other.scrmem)
855 {
856 alloc_scriptmem();
857 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
858
859 scrmem->scriptData = other.scrmem->scriptData;
860 }
861 else scrmem = NULL;
862 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
863 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
864
865 for(int32_t i=0; i<edefLAST255; i++)
866 defense[i]=other.defense[i];
867 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
868 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
869
870 if(new_script_uid)
871 {
872 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
873 }
874 if(clear_parent_script_UID)
875 {
876 parent_script_UID = 0;
877 }
878 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
879 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
880
881 for ( int32_t q = 0; q < 8; q++ )
882 {
883 initD[q] = other.initD[q];
884 weap_initiald[q] = other.weap_initiald[q];
885 }
886 for ( int32_t q = 0; q < 2; q++ )
887 {
888 initA[q] = other.initA[q];
889 weap_initiala[q] = other.weap_initiala[q];
890 }
891 }
892
893 eZora::eZora(eZora const & other, bool new_script_uid, bool clear_parent_script_UID):
894 //Struct Element Type Purpose
895 //sprite(other),
896 enemy(other)
897 {
898
899 //arrays
900
901 if(other.scrmem)
902 {
903 alloc_scriptmem();
904 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
905
906 scrmem->scriptData = other.scrmem->scriptData;
907 }
908 else scrmem = NULL;
909 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
910 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
911
912 for(int32_t i=0; i<edefLAST255; i++)
913 defense[i]=other.defense[i];
914 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
915 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
916
917 if(new_script_uid)
918 {
919 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
920 }
921 if(clear_parent_script_UID)
922 {
923 parent_script_UID = 0;
924 }
925 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
926 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
927
928 for ( int32_t q = 0; q < 8; q++ )
929 {
930 initD[q] = other.initD[q];
931 weap_initiald[q] = other.weap_initiald[q];
932 }
933 for ( int32_t q = 0; q < 2; q++ )
934 {
935 initA[q] = other.initA[q];
936 weap_initiala[q] = other.weap_initiala[q];
937 }
938 }
939
940 eSpinTile::eSpinTile(eSpinTile const & other, bool new_script_uid, bool clear_parent_script_UID):
941 //Struct Element Type Purpose
942 //sprite(other),
943 enemy(other)
944 {
945
946 //arrays
947
948 if(other.scrmem)
949 {
950 alloc_scriptmem();
951 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
952
953 scrmem->scriptData = other.scrmem->scriptData;
954 }
955 else scrmem = NULL;
956 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
957 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
958
959 for(int32_t i=0; i<edefLAST255; i++)
960 defense[i]=other.defense[i];
961 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
962 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
963
964 if(new_script_uid)
965 {
966 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
967 }
968 if(clear_parent_script_UID)
969 {
970 parent_script_UID = 0;
971 }
972 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
973 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
974
975 for ( int32_t q = 0; q < 8; q++ )
976 {
977 initD[q] = other.initD[q];
978 weap_initiald[q] = other.weap_initiald[q];
979 }
980 for ( int32_t q = 0; q < 2; q++ )
981 {
982 initA[q] = other.initA[q];
983 weap_initiala[q] = other.weap_initiala[q];
984 }
985 }
986
987 eNPC::eNPC(eNPC const & other, bool new_script_uid, bool clear_parent_script_UID):
988 //Struct Element Type Purpose
989 //sprite(other),
990 enemy(other)
991 {
992
993 //arrays
994
995 if(other.scrmem)
996 {
997 alloc_scriptmem();
998 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
999
1000 scrmem->scriptData = other.scrmem->scriptData;
1001 }
1002 else scrmem = NULL;
1003 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1004 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1005
1006 for(int32_t i=0; i<edefLAST255; i++)
1007 defense[i]=other.defense[i];
1008 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1009 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1010
1011 if(new_script_uid)
1012 {
1013 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1014 }
1015 if(clear_parent_script_UID)
1016 {
1017 parent_script_UID = 0;
1018 }
1019 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1020 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1021
1022 for ( int32_t q = 0; q < 8; q++ )
1023 {
1024 initD[q] = other.initD[q];
1025 weap_initiald[q] = other.weap_initiald[q];
1026 }
1027 for ( int32_t q = 0; q < 2; q++ )
1028 {
1029 initA[q] = other.initA[q];
1030 weap_initiala[q] = other.weap_initiala[q];
1031 }
1032 }
1033
1034 eTrigger::eTrigger(eTrigger const & other, bool new_script_uid, bool clear_parent_script_UID):
1035 //Struct Element Type Purpose
1036 //sprite(other),
1037 enemy(other)
1038 {
1039
1040 //arrays
1041
1042 if(other.scrmem)
1043 {
1044 alloc_scriptmem();
1045 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1046
1047 scrmem->scriptData = other.scrmem->scriptData;
1048 }
1049 else scrmem = NULL;
1050 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1051 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1052
1053 for(int32_t i=0; i<edefLAST255; i++)
1054 defense[i]=other.defense[i];
1055 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1056 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1057
1058 if(new_script_uid)
1059 {
1060 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1061 }
1062 if(clear_parent_script_UID)
1063 {
1064 parent_script_UID = 0;
1065 }
1066 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1067 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1068
1069 for ( int32_t q = 0; q < 8; q++ )
1070 {
1071 initD[q] = other.initD[q];
1072 weap_initiald[q] = other.weap_initiald[q];
1073 }
1074 for ( int32_t q = 0; q < 2; q++ )
1075 {
1076 initA[q] = other.initA[q];
1077 weap_initiala[q] = other.weap_initiala[q];
1078 }
1079 }
1080
1081 eProjectile::eProjectile(eProjectile const & other, bool new_script_uid, bool clear_parent_script_UID):
1082 //Struct Element Type Purpose
1083 //sprite(other),
1084 enemy(other),
1085 minRange(other.minRange)
1086 {
1087
1088 //arrays
1089
1090 if(other.scrmem)
1091 {
1092 alloc_scriptmem();
1093 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1094
1095 scrmem->scriptData = other.scrmem->scriptData;
1096 }
1097 else scrmem = NULL;
1098 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1099 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1100
1101 for(int32_t i=0; i<edefLAST255; i++)
1102 defense[i]=other.defense[i];
1103 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1104 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1105
1106 if(new_script_uid)
1107 {
1108 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1109 }
1110 if(clear_parent_script_UID)
1111 {
1112 parent_script_UID = 0;
1113 }
1114 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1115 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1116
1117 for ( int32_t q = 0; q < 8; q++ )
1118 {
1119 initD[q] = other.initD[q];
1120 weap_initiald[q] = other.weap_initiald[q];
1121 }
1122 for ( int32_t q = 0; q < 2; q++ )
1123 {
1124 initA[q] = other.initA[q];
1125 weap_initiala[q] = other.weap_initiala[q];
1126 }
1127 }
1128
1129 eBoulder::eBoulder(eBoulder const & other, bool new_script_uid, bool clear_parent_script_UID):
1130 //Struct Element Type Purpose
1131 //sprite(other),
1132 enemy(other)
1133 {
1134
1135 //arrays
1136
1137 if(other.scrmem)
1138 {
1139 alloc_scriptmem();
1140 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1141
1142 scrmem->scriptData = other.scrmem->scriptData;
1143 }
1144 else scrmem = NULL;
1145 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1146 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1147
1148 for(int32_t i=0; i<edefLAST255; i++)
1149 defense[i]=other.defense[i];
1150 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1151 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1152
1153 if(new_script_uid)
1154 {
1155 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1156 }
1157 if(clear_parent_script_UID)
1158 {
1159 parent_script_UID = 0;
1160 }
1161 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1162 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1163
1164 for ( int32_t q = 0; q < 8; q++ )
1165 {
1166 initD[q] = other.initD[q];
1167 weap_initiald[q] = other.weap_initiald[q];
1168 }
1169 for ( int32_t q = 0; q < 2; q++ )
1170 {
1171 initA[q] = other.initA[q];
1172 weap_initiala[q] = other.weap_initiala[q];
1173 }
1174 }
1175
1176 eRock::eRock(eRock const & other, bool new_script_uid, bool clear_parent_script_UID):
1177 //Struct Element Type Purpose
1178 //sprite(other),
1179 enemy(other)
1180 {
1181
1182 //arrays
1183
1184 if(other.scrmem)
1185 {
1186 alloc_scriptmem();
1187 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1188
1189 scrmem->scriptData = other.scrmem->scriptData;
1190 }
1191 else scrmem = NULL;
1192 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1193 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1194
1195 for(int32_t i=0; i<edefLAST255; i++)
1196 defense[i]=other.defense[i];
1197 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1198 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1199
1200 if(new_script_uid)
1201 {
1202 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1203 }
1204 if(clear_parent_script_UID)
1205 {
1206 parent_script_UID = 0;
1207 }
1208 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1209 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1210
1211 for ( int32_t q = 0; q < 8; q++ )
1212 {
1213 initD[q] = other.initD[q];
1214 weap_initiald[q] = other.weap_initiald[q];
1215 }
1216 for ( int32_t q = 0; q < 2; q++ )
1217 {
1218 initA[q] = other.initA[q];
1219 weap_initiala[q] = other.weap_initiala[q];
1220 }
1221 }
1222
1223 eTrap2::eTrap2(eTrap2 const & other, bool new_script_uid, bool clear_parent_script_UID):
1224 //Struct Element Type Purpose
1225 //sprite(other),
1226 enemy(other)
1227 {
1228
1229 //arrays
1230
1231 if(other.scrmem)
1232 {
1233 alloc_scriptmem();
1234 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1235
1236 scrmem->scriptData = other.scrmem->scriptData;
1237 }
1238 else scrmem = NULL;
1239 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1240 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1241
1242 for(int32_t i=0; i<edefLAST255; i++)
1243 defense[i]=other.defense[i];
1244 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1245 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1246
1247 if(new_script_uid)
1248 {
1249 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1250 }
1251 if(clear_parent_script_UID)
1252 {
1253 parent_script_UID = 0;
1254 }
1255 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1256 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1257
1258 for ( int32_t q = 0; q < 8; q++ )
1259 {
1260 initD[q] = other.initD[q];
1261 weap_initiald[q] = other.weap_initiald[q];
1262 }
1263 for ( int32_t q = 0; q < 2; q++ )
1264 {
1265 initA[q] = other.initA[q];
1266 weap_initiala[q] = other.weap_initiala[q];
1267 }
1268 }
1269
1270 eTrap::eTrap(eTrap const & other, bool new_script_uid, bool clear_parent_script_UID):
1271 //Struct Element Type Purpose
1272 //sprite(other),
1273 enemy(other),
1274 ox(other.ox),
1275 oy(other.oy)
1276 {
1277
1278 //arrays
1279
1280 if(other.scrmem)
1281 {
1282 alloc_scriptmem();
1283 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1284
1285 scrmem->scriptData = other.scrmem->scriptData;
1286 }
1287 else scrmem = NULL;
1288 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1289 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1290
1291 for(int32_t i=0; i<edefLAST255; i++)
1292 defense[i]=other.defense[i];
1293 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1294 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1295
1296 if(new_script_uid)
1297 {
1298 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1299 }
1300 if(clear_parent_script_UID)
1301 {
1302 parent_script_UID = 0;
1303 }
1304 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1305 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1306
1307 for ( int32_t q = 0; q < 8; q++ )
1308 {
1309 initD[q] = other.initD[q];
1310 weap_initiald[q] = other.weap_initiald[q];
1311 }
1312 for ( int32_t q = 0; q < 2; q++ )
1313 {
1314 initA[q] = other.initA[q];
1315 weap_initiala[q] = other.weap_initiala[q];
1316 }
1317 }
1318
1319
1320
1321
1322 eKeese::eKeese(eKeese const & other, bool new_script_uid, bool clear_parent_script_UID):
1323 //Struct Element Type Purpose
1324 //sprite(other),
1325 enemy(other),
1326 ox(other.ox),
1327 c(other.c),
1328 clk4(other.clk4),
1329 oy(other.oy)
1330 {
1331
1332 //arrays
1333
1334 if(other.scrmem)
1335 {
1336 alloc_scriptmem();
1337 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1338
1339 scrmem->scriptData = other.scrmem->scriptData;
1340 }
1341 else scrmem = NULL;
1342 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1343 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1344
1345 for(int32_t i=0; i<edefLAST255; i++)
1346 defense[i]=other.defense[i];
1347 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1348 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1349
1350 if(new_script_uid)
1351 {
1352 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1353 }
1354 if(clear_parent_script_UID)
1355 {
1356 parent_script_UID = 0;
1357 }
1358 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1359 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1360
1361 for ( int32_t q = 0; q < 8; q++ )
1362 {
1363 initD[q] = other.initD[q];
1364 weap_initiald[q] = other.weap_initiald[q];
1365 }
1366 for ( int32_t q = 0; q < 2; q++ )
1367 {
1368 initA[q] = other.initA[q];
1369 weap_initiala[q] = other.weap_initiala[q];
1370 }
1371 }
1372
1373 eWizzrobe::eWizzrobe(eWizzrobe const & other, bool new_script_uid, bool clear_parent_script_UID):
1374 //Struct Element Type Purpose
1375 //sprite(other),
1376 enemy(other),
1377 charging(other.charging),
1378 firing(other.firing),
1379 fclk(other.fclk)
1380 {
1381
1382 //arrays
1383
1384 if(other.scrmem)
1385 {
1386 alloc_scriptmem();
1387 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1388
1389 scrmem->scriptData = other.scrmem->scriptData;
1390 }
1391 else scrmem = NULL;
1392 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1393 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1394
1395 for(int32_t i=0; i<edefLAST255; i++)
1396 defense[i]=other.defense[i];
1397 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1398 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1399
1400 if(new_script_uid)
1401 {
1402 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1403 }
1404 if(clear_parent_script_UID)
1405 {
1406 parent_script_UID = 0;
1407 }
1408 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1409 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1410
1411 for ( int32_t q = 0; q < 8; q++ )
1412 {
1413 initD[q] = other.initD[q];
1414 weap_initiald[q] = other.weap_initiald[q];
1415 }
1416 for ( int32_t q = 0; q < 2; q++ )
1417 {
1418 initA[q] = other.initA[q];
1419 weap_initiala[q] = other.weap_initiala[q];
1420 }
1421 }
1422
1423 eDodongo::eDodongo(eDodongo const & other, bool new_script_uid, bool clear_parent_script_UID):
1424 //Struct Element Type Purpose
1425 //sprite(other),
1426 enemy(other)
1427 {
1428
1429 //arrays
1430
1431 if(other.scrmem)
1432 {
1433 alloc_scriptmem();
1434 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1435
1436 scrmem->scriptData = other.scrmem->scriptData;
1437 }
1438 else scrmem = NULL;
1439 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1440 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1441
1442 for(int32_t i=0; i<edefLAST255; i++)
1443 defense[i]=other.defense[i];
1444 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1445 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1446
1447 if(new_script_uid)
1448 {
1449 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1450 }
1451 if(clear_parent_script_UID)
1452 {
1453 parent_script_UID = 0;
1454 }
1455 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1456 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1457
1458 for ( int32_t q = 0; q < 8; q++ )
1459 {
1460 initD[q] = other.initD[q];
1461 weap_initiald[q] = other.weap_initiald[q];
1462 }
1463 for ( int32_t q = 0; q < 2; q++ )
1464 {
1465 initA[q] = other.initA[q];
1466 weap_initiala[q] = other.weap_initiala[q];
1467 }
1468 }
1469
1470 eDodongo2::eDodongo2(eDodongo2 const & other, bool new_script_uid, bool clear_parent_script_UID):
1471 //Struct Element Type Purpose
1472 //sprite(other),
1473 enemy(other),
1474 previous_dir(other.previous_dir)
1475 {
1476
1477 //arrays
1478
1479 if(other.scrmem)
1480 {
1481 alloc_scriptmem();
1482 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1483
1484 scrmem->scriptData = other.scrmem->scriptData;
1485 }
1486 else scrmem = NULL;
1487 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1488 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1489
1490 for(int32_t i=0; i<edefLAST255; i++)
1491 defense[i]=other.defense[i];
1492 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1493 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1494
1495 if(new_script_uid)
1496 {
1497 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1498 }
1499 if(clear_parent_script_UID)
1500 {
1501 parent_script_UID = 0;
1502 }
1503 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1504 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1505
1506 for ( int32_t q = 0; q < 8; q++ )
1507 {
1508 initD[q] = other.initD[q];
1509 weap_initiald[q] = other.weap_initiald[q];
1510 }
1511 for ( int32_t q = 0; q < 2; q++ )
1512 {
1513 initA[q] = other.initA[q];
1514 weap_initiala[q] = other.weap_initiala[q];
1515 }
1516 }
1517
1518 eAquamentus::eAquamentus(eAquamentus const & other, bool new_script_uid, bool clear_parent_script_UID):
1519 //Struct Element Type Purpose
1520 //sprite(other),
1521 enemy(other),
1522 fbx(other.fbx),
1523 clk4(other.clk4)
1524 {
1525
1526 //arrays
1527
1528 if(other.scrmem)
1529 {
1530 alloc_scriptmem();
1531 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1532
1533 scrmem->scriptData = other.scrmem->scriptData;
1534 }
1535 else scrmem = NULL;
1536 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1537 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1538
1539 for(int32_t i=0; i<edefLAST255; i++)
1540 defense[i]=other.defense[i];
1541 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1542 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1543
1544 if(new_script_uid)
1545 {
1546 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1547 }
1548 if(clear_parent_script_UID)
1549 {
1550 parent_script_UID = 0;
1551 }
1552 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1553 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1554
1555 for ( int32_t q = 0; q < 8; q++ )
1556 {
1557 initD[q] = other.initD[q];
1558 weap_initiald[q] = other.weap_initiald[q];
1559 }
1560 for ( int32_t q = 0; q < 2; q++ )
1561 {
1562 initA[q] = other.initA[q];
1563 weap_initiala[q] = other.weap_initiala[q];
1564 }
1565 }
1566
1567 eGohma::eGohma(eGohma const & other, bool new_script_uid, bool clear_parent_script_UID):
1568 //Struct Element Type Purpose
1569 //sprite(other),
1570 enemy(other),
1571 clk4(other.clk4)
1572 {
1573
1574 //arrays
1575
1576 if(other.scrmem)
1577 {
1578 alloc_scriptmem();
1579 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1580
1581 scrmem->scriptData = other.scrmem->scriptData;
1582 }
1583 else scrmem = NULL;
1584 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1585 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1586
1587 for(int32_t i=0; i<edefLAST255; i++)
1588 defense[i]=other.defense[i];
1589 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1590 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1591
1592 if(new_script_uid)
1593 {
1594 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1595 }
1596 if(clear_parent_script_UID)
1597 {
1598 parent_script_UID = 0;
1599 }
1600 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1601 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1602
1603 for ( int32_t q = 0; q < 8; q++ )
1604 {
1605 initD[q] = other.initD[q];
1606 weap_initiald[q] = other.weap_initiald[q];
1607 }
1608 for ( int32_t q = 0; q < 2; q++ )
1609 {
1610 initA[q] = other.initA[q];
1611 weap_initiala[q] = other.weap_initiala[q];
1612 }
1613 }
1614
1615 eLilDig::eLilDig(eLilDig const & other, bool new_script_uid, bool clear_parent_script_UID):
1616 //Struct Element Type Purpose
1617 //sprite(other),
1618 enemy(other)
1619 {
1620
1621 //arrays
1622
1623 if(other.scrmem)
1624 {
1625 alloc_scriptmem();
1626 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1627
1628 scrmem->scriptData = other.scrmem->scriptData;
1629 }
1630 else scrmem = NULL;
1631 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1632 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1633
1634 for(int32_t i=0; i<edefLAST255; i++)
1635 defense[i]=other.defense[i];
1636 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1637 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1638
1639 if(new_script_uid)
1640 {
1641 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1642 }
1643 if(clear_parent_script_UID)
1644 {
1645 parent_script_UID = 0;
1646 }
1647 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1648 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1649
1650 for ( int32_t q = 0; q < 8; q++ )
1651 {
1652 initD[q] = other.initD[q];
1653 weap_initiald[q] = other.weap_initiald[q];
1654 }
1655 for ( int32_t q = 0; q < 2; q++ )
1656 {
1657 initA[q] = other.initA[q];
1658 weap_initiala[q] = other.weap_initiala[q];
1659 }
1660 }
1661
1662 eBigDig::eBigDig(eBigDig const & other, bool new_script_uid, bool clear_parent_script_UID):
1663 //Struct Element Type Purpose
1664 //sprite(other),
1665 enemy(other)
1666 {
1667
1668 //arrays
1669
1670 if(other.scrmem)
1671 {
1672 alloc_scriptmem();
1673 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1674
1675 scrmem->scriptData = other.scrmem->scriptData;
1676 }
1677 else scrmem = NULL;
1678 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1679 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1680
1681 for(int32_t i=0; i<edefLAST255; i++)
1682 defense[i]=other.defense[i];
1683 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1684 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1685
1686 if(new_script_uid)
1687 {
1688 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1689 }
1690 if(clear_parent_script_UID)
1691 {
1692 parent_script_UID = 0;
1693 }
1694 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1695 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1696
1697 for ( int32_t q = 0; q < 8; q++ )
1698 {
1699 initD[q] = other.initD[q];
1700 weap_initiald[q] = other.weap_initiald[q];
1701 }
1702 for ( int32_t q = 0; q < 2; q++ )
1703 {
1704 initA[q] = other.initA[q];
1705 weap_initiala[q] = other.weap_initiala[q];
1706 }
1707 }
1708
1709 eGanon::eGanon(eGanon const & other, bool new_script_uid, bool clear_parent_script_UID):
1710 //Struct Element Type Purpose
1711 //sprite(other),
1712 enemy(other),
1713 Stunclk(other.Stunclk)
1714
1715 {
1716
1717 //arrays
1718
1719 if(other.scrmem)
1720 {
1721 alloc_scriptmem();
1722 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1723
1724 scrmem->scriptData = other.scrmem->scriptData;
1725 }
1726 else scrmem = NULL;
1727 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1728 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1729
1730 for(int32_t i=0; i<edefLAST255; i++)
1731 defense[i]=other.defense[i];
1732 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1733 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1734
1735 if(new_script_uid)
1736 {
1737 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1738 }
1739 if(clear_parent_script_UID)
1740 {
1741 parent_script_UID = 0;
1742 }
1743 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1744 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1745
1746 for ( int32_t q = 0; q < 8; q++ )
1747 {
1748 initD[q] = other.initD[q];
1749 weap_initiald[q] = other.weap_initiald[q];
1750 }
1751 for ( int32_t q = 0; q < 2; q++ )
1752 {
1753 initA[q] = other.initA[q];
1754 weap_initiala[q] = other.weap_initiala[q];
1755 }
1756 }
1757
1758 eMoldorm::eMoldorm(eMoldorm const & other, bool new_script_uid, bool clear_parent_script_UID):
1759 //Struct Element Type Purpose
1760 //sprite(other),
1761 enemy(other),
1762 segcnt(other.segcnt),
1763 segid(other.segid)
1764
1765 {
1766
1767 //arrays
1768
1769 if(other.scrmem)
1770 {
1771 alloc_scriptmem();
1772 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1773
1774 scrmem->scriptData = other.scrmem->scriptData;
1775 }
1776 else scrmem = NULL;
1777 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1778 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1779
1780 for(int32_t i=0; i<edefLAST255; i++)
1781 defense[i]=other.defense[i];
1782 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1783 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1784
1785 if(new_script_uid)
1786 {
1787 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1788 }
1789 if(clear_parent_script_UID)
1790 {
1791 parent_script_UID = 0;
1792 }
1793 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1794 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1795
1796 for ( int32_t q = 0; q < 8; q++ )
1797 {
1798 initD[q] = other.initD[q];
1799 weap_initiald[q] = other.weap_initiald[q];
1800 }
1801 for ( int32_t q = 0; q < 2; q++ )
1802 {
1803 initA[q] = other.initA[q];
1804 weap_initiala[q] = other.weap_initiala[q];
1805 }
1806 }
1807
1808 esMoldorm::esMoldorm(esMoldorm const & other, bool new_script_uid, bool clear_parent_script_UID):
1809 //Struct Element Type Purpose
1810 //sprite(other),
1811 enemy(other),
1812 parentclk(other.parentclk)
1813 {
1814
1815 //arrays
1816
1817 if(other.scrmem)
1818 {
1819 alloc_scriptmem();
1820 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1821
1822 scrmem->scriptData = other.scrmem->scriptData;
1823 }
1824 else scrmem = NULL;
1825 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1826 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1827
1828 for(int32_t i=0; i<edefLAST255; i++)
1829 defense[i]=other.defense[i];
1830 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1831 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1832
1833 if(new_script_uid)
1834 {
1835 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1836 }
1837 if(clear_parent_script_UID)
1838 {
1839 parent_script_UID = 0;
1840 }
1841 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1842 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1843
1844 for ( int32_t q = 0; q < 8; q++ )
1845 {
1846 initD[q] = other.initD[q];
1847 weap_initiald[q] = other.weap_initiald[q];
1848 }
1849 for ( int32_t q = 0; q < 2; q++ )
1850 {
1851 initA[q] = other.initA[q];
1852 weap_initiala[q] = other.weap_initiala[q];
1853 }
1854 }
1855 /*
1856 eManhandla::eManhandla(eManhandla const & other, bool new_script_uid, bool clear_parent_script_UID):
1857 //Struct Element Type Purpose
1858 //sprite(other),
1859 enemy(other),
1860 armcnt(armcnt),
1861 adjusted(adjusted),
1862 arm[0](arm[0]),
1863 arm[1](arm[1]),
1864 arm[2](arm[2]),
1865 arm[3](arm[3]),
1866 arm[4](arm[4]),
1867 arm[5](arm[5]),
1868 arm[6](arm[6]),
1869 arm[7](arm[7])
1870 {
1871
1872 //arrays
1873 if(other.scrmem)
1874 {
1875 alloc_scriptmem();
1876 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1877
1878 scrmem->scriptData = other.scrmem->scriptData;
1879 }
1880 else scrmem = NULL;
1881 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1882 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1883
1884 for(int32_t i=0; i<edefLAST255; i++)
1885 defense[i]=other.defense[i];
1886 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1887 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1888
1889 if(new_script_uid)
1890 {
1891 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1892 }
1893 if(clear_parent_script_UID)
1894 {
1895 parent_script_UID = 0;
1896 }
1897 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1898 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1899
1900 for ( int32_t q = 0; q < 8; q++ )
1901 {
1902 initD[q] = other.initD[q];
1903 weap_initiald[q] = other.weap_initiald[q];
1904 }
1905 for ( int32_t q = 0; q < 2; q++ )
1906 {
1907 initA[q] = other.initA[q];
1908 weap_initiala[q] = other.weap_initiala[q];
1909 }
1910 }
1911
1912 esManhandla::esManhandla(esManhandla const & other, bool new_script_uid, bool clear_parent_script_UID):
1913 //Struct Element Type Purpose
1914 //sprite(other),
1915 enemy(other)
1916 {
1917
1918 //arrays
1919 if(other.scrmem)
1920 {
1921 alloc_scriptmem();
1922 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1923
1924 scrmem->scriptData = other.scrmem->scriptData;
1925 }
1926 else scrmem = NULL;
1927 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1928 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1929
1930 for(int32_t i=0; i<edefLAST255; i++)
1931 defense[i]=other.defense[i];
1932 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1933 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1934
1935 if(new_script_uid)
1936 {
1937 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1938 }
1939 if(clear_parent_script_UID)
1940 {
1941 parent_script_UID = 0;
1942 }
1943 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1944 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1945
1946 for ( int32_t q = 0; q < 8; q++ )
1947 {
1948 initD[q] = other.initD[q];
1949 weap_initiald[q] = other.weap_initiald[q];
1950 }
1951 for ( int32_t q = 0; q < 2; q++ )
1952 {
1953 initA[q] = other.initA[q];
1954 weap_initiala[q] = other.weap_initiala[q];
1955 }
1956 }
1957
1958 eGleeok::eGleeok(eGleeok const & other, bool new_script_uid, bool clear_parent_script_UID):
1959 //Struct Element Type Purpose
1960 //sprite(other),
1961 enemy(other),
1962 flameclk(flameclk),
1963 flamehead(flamehead),
1964 necktile(necktile)
1965
1966 {
1967
1968 //arrays
1969
1970 if(other.scrmem)
1971 {
1972 alloc_scriptmem();
1973 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1974
1975 scrmem->scriptData = other.scrmem->scriptData;
1976 }
1977 else scrmem = NULL;
1978 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1979 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1980
1981 for(int32_t i=0; i<edefLAST255; i++)
1982 defense[i]=other.defense[i];
1983 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1984 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1985
1986 if(new_script_uid)
1987 {
1988 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1989 }
1990 if(clear_parent_script_UID)
1991 {
1992 parent_script_UID = 0;
1993 }
1994 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1995 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1996
1997 for ( int32_t q = 0; q < 8; q++ )
1998 {
1999 initD[q] = other.initD[q];
2000 weap_initiald[q] = other.weap_initiald[q];
2001 }
2002 for ( int32_t q = 0; q < 2; q++ )
2003 {
2004 initA[q] = other.initA[q];
2005 weap_initiala[q] = other.weap_initiala[q];
2006 }
2007 }
2008
2009 esGleeok::esGleeok(esGleeok const & other, bool new_script_uid, bool clear_parent_script_UID):
2010 //Struct Element Type Purpose
2011 //sprite(other),
2012 enemy(other),
2013 headtile(headtile),
2014 flyingheadtile(flyingheadtile),
2015 necktile(necktile),
2016 xoffset(xoffset),
2017 yoffset(yoffset),
2018 nx(nx),
2019 ny(ny),
2020 nxoffset(nxoffset),
2021 nyoffset(nyoffset),
2022 parent(parent)
2023
2024 {
2025
2026 //arrays
2027
2028 if(other.scrmem)
2029 {
2030 alloc_scriptmem();
2031 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2032
2033 scrmem->scriptData = other.scrmem->scriptData;
2034 }
2035 else scrmem = NULL;
2036 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2037 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2038
2039 //for ( int32_t q = 0; q < 255; q++ )
2040 //{
2041 // nx[q] = other.nx[q];
2042 // ny[q] = other.ny[q];
2043 // nxoffset[q] = other.nxoffset[q];
2044 // nyoffset[q] = other.nyoffset[q];
2045 //}
2046
2047 for(int32_t i=0; i<edefLAST255; i++)
2048 defense[i]=other.defense[i];
2049 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2050 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2051
2052 if(new_script_uid)
2053 {
2054 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2055 }
2056 if(clear_parent_script_UID)
2057 {
2058 parent_script_UID = 0;
2059 }
2060 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2061 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2062
2063 for ( int32_t q = 0; q < 8; q++ )
2064 {
2065 initD[q] = other.initD[q];
2066 weap_initiald[q] = other.weap_initiald[q];
2067 }
2068 for ( int32_t q = 0; q < 2; q++ )
2069 {
2070 initA[q] = other.initA[q];
2071 weap_initiala[q] = other.weap_initiala[q];
2072 }
2073 }
2074
2075 ePatra::ePatra(ePatra const & other, bool new_script_uid, bool clear_parent_script_UID):
2076 //Struct Element Type Purpose
2077 //sprite(other),
2078 enemy(other),
2079 flycnt(flycnt),
2080 flycnt2(flycnt2),
2081 loopcnt(loopcnt),
2082 lookat(lookat),
2083 circle_x(circle_x),
2084 circle_y(circle_y),
2085 temp_x(temp_x),
2086 temp_y(temp_y),
2087 adjusted(adjusted)
2088
2089 {
2090
2091 //arrays
2092
2093 if(other.scrmem)
2094 {
2095 alloc_scriptmem();
2096 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2097
2098 scrmem->scriptData = other.scrmem->scriptData;
2099 }
2100 else scrmem = NULL;
2101 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2102 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2103
2104 for(int32_t i=0; i<edefLAST255; i++)
2105 defense[i]=other.defense[i];
2106 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2107 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2108
2109 if(new_script_uid)
2110 {
2111 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2112 }
2113 if(clear_parent_script_UID)
2114 {
2115 parent_script_UID = 0;
2116 }
2117 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2118 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2119
2120 for ( int32_t q = 0; q < 8; q++ )
2121 {
2122 initD[q] = other.initD[q];
2123 weap_initiald[q] = other.weap_initiald[q];
2124 }
2125 for ( int32_t q = 0; q < 2; q++ )
2126 {
2127 initA[q] = other.initA[q];
2128 weap_initiala[q] = other.weap_initiala[q];
2129 }
2130 }
2131
2132 ePatraBS::ePatraBS(ePatraBS const & other, bool new_script_uid, bool clear_parent_script_UID):
2133 //Struct Element Type Purpose
2134 //sprite(other),
2135 enemy(other),
2136 flycnt(flycnt),
2137 flycnt2(flycnt2),
2138 loopcnt(loopcnt),
2139 lookat(lookat),
2140 adjusted(adjusted)
2141
2142 {
2143
2144 //arrays
2145
2146 if(other.scrmem)
2147 {
2148 alloc_scriptmem();
2149 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2150
2151 scrmem->scriptData = other.scrmem->scriptData;
2152 }
2153 else scrmem = NULL;
2154 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2155 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2156
2157 for(int32_t i=0; i<edefLAST255; i++)
2158 defense[i]=other.defense[i];
2159 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2160 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2161
2162 if(new_script_uid)
2163 {
2164 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2165 }
2166 if(clear_parent_script_UID)
2167 {
2168 parent_script_UID = 0;
2169 }
2170 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2171 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2172
2173 for ( int32_t q = 0; q < 8; q++ )
2174 {
2175 initD[q] = other.initD[q];
2176 weap_initiald[q] = other.weap_initiald[q];
2177 }
2178 for ( int32_t q = 0; q < 2; q++ )
2179 {
2180 initA[q] = other.initA[q];
2181 weap_initiala[q] = other.weap_initiala[q];
2182 }
2183 }
2184
2185 esPatra::esPatra(esPatra const & other, bool new_script_uid, bool clear_parent_script_UID):
2186 //Struct Element Type Purpose
2187 //sprite(other),
2188 enemy(other)
2189
2190 {
2191
2192 //arrays
2193
2194 if(other.scrmem)
2195 {
2196 alloc_scriptmem();
2197 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2198
2199 scrmem->scriptData = other.scrmem->scriptData;
2200 }
2201 else scrmem = NULL;
2202 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2203 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2204
2205 for ( int32_t q = 0; q < 255; q++ )
2206 {
2207 nx[q] = other.nx[q];
2208 ny[q] = other.ny[q];
2209 nxoffset[q] = other.nxoffset[q];
2210 nyoffset[q] = other.nyoffset[q];
2211 }
2212
2213 for(int32_t i=0; i<edefLAST255; i++)
2214 defense[i]=other.defense[i];
2215 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2216 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2217
2218 if(new_script_uid)
2219 {
2220 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2221 }
2222 if(clear_parent_script_UID)
2223 {
2224 parent_script_UID = 0;
2225 }
2226 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2227 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2228
2229 for ( int32_t q = 0; q < 8; q++ )
2230 {
2231 initD[q] = other.initD[q];
2232 weap_initiald[q] = other.weap_initiald[q];
2233 }
2234 for ( int32_t q = 0; q < 2; q++ )
2235 {
2236 initA[q] = other.initA[q];
2237 weap_initiala[q] = other.weap_initiala[q];
2238 }
2239 }
2240
2241 esPatraBS::esPatraBS(esPatraBS const & other, bool new_script_uid, bool clear_parent_script_UID):
2242 //Struct Element Type Purpose
2243 //sprite(other),
2244 enemy(other)
2245
2246 {
2247
2248 //arrays
2249
2250 if(other.scrmem)
2251 {
2252 alloc_scriptmem();
2253 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2254
2255 scrmem->scriptData = other.scrmem->scriptData;
2256 }
2257 else scrmem = NULL;
2258 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2259 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2260
2261 for ( int32_t q = 0; q < 255; q++ )
2262 {
2263 nx[q] = other.nx[q];
2264 ny[q] = other.ny[q];
2265 nxoffset[q] = other.nxoffset[q];
2266 nyoffset[q] = other.nyoffset[q];
2267 }
2268
2269 for(int32_t i=0; i<edefLAST255; i++)
2270 defense[i]=other.defense[i];
2271 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2272 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2273
2274 if(new_script_uid)
2275 {
2276 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2277 }
2278 if(clear_parent_script_UID)
2279 {
2280 parent_script_UID = 0;
2281 }
2282 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2283 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2284
2285 for ( int32_t q = 0; q < 8; q++ )
2286 {
2287 initD[q] = other.initD[q];
2288 weap_initiald[q] = other.weap_initiald[q];
2289 }
2290 for ( int32_t q = 0; q < 2; q++ )
2291 {
2292 initA[q] = other.initA[q];
2293 weap_initiala[q] = other.weap_initiala[q];
2294 }
2295 }
2296
2297 */
2298
2299
5/10
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37112 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 37112 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 37112 times.
✗ Branch 9 not taken.
111336 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
2300 74224 {
2301
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 x=X;
2302
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 y=Y;
2303 37112 id=Id;
2304 37112 clk=Clk;
2305
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 floor_y=y;
2306 37112 ceiling=false;
2307 37112 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
2308 37112 grumble = movestatus = posframe = timer = ox = oy = 0;
2309
4/8
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37112 times.
✓ Branch 4 taken 37112 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 37112 times.
✗ Branch 7 not taken.
37112 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
2310 37112 did_armos=true;
2311 37112 script_spawned=false;
2312
2313 37112 d = guysbuf + (id & 0xFFF);
2314 37112 hp = d->hp;
2315 37112 starting_hp = hp;
2316 // cs = d->cset;
2317 //d variables
2318
2319 37112 flags=d->flags;
2320 37112 flags2=d->flags2;
2321 37112 s_tile=d->s_tile; //secondary (additional) tile(s)
2322 37112 family=d->family;
2323 37112 dcset=d->cset;
2324 37112 cs=dcset;
2325
3/4
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27523 times.
✓ Branch 3 taken 9589 times.
37112 anim=get_bit(quest_rules,qr_NEWENEMYTILES)?d->e_anim:d->anim;
2326 37112 dp=d->dp;
2327 37112 wdp=d->wdp;
2328 37112 wpn=d->weapon;
2329 37112 wpnsprite = d-> wpnsprite; //2.6 -Z
2330 37112 rate=d->rate;
2331 37112 hrate=d->hrate;
2332
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 dstep=d->step;
2333 37112 homing=d->homing;
2334 37112 dmisc1=d->misc1;
2335 37112 dmisc2=d->misc2;
2336 37112 dmisc3=d->misc3;
2337 37112 dmisc4=d->misc4;
2338 37112 dmisc5=d->misc5;
2339 37112 dmisc6=d->misc6;
2340 37112 dmisc7=d->misc7;
2341 37112 dmisc8=d->misc8;
2342 37112 dmisc9=d->misc9;
2343 37112 dmisc10=d->misc10;
2344 37112 dmisc11=d->misc11;
2345 37112 dmisc12=d->misc12;
2346 37112 dmisc13=d->misc13;
2347 37112 dmisc14=d->misc14;
2348 37112 dmisc15=d->misc15;
2349 37112 dmisc16=d->misc16;
2350 37112 dmisc17=d->misc17;
2351 37112 dmisc18=d->misc18;
2352 37112 dmisc19=d->misc19;
2353 37112 dmisc20=d->misc20;
2354 37112 dmisc21=d->misc21;
2355 37112 dmisc22=d->misc22;
2356 37112 dmisc23=d->misc23;
2357 37112 dmisc24=d->misc24;
2358 37112 dmisc25=d->misc25;
2359 37112 dmisc26=d->misc26;
2360 37112 dmisc27=d->misc27;
2361 37112 dmisc28=d->misc28;
2362 37112 dmisc29=d->misc29;
2363 37112 dmisc30=d->misc30;
2364 37112 dmisc31=d->misc31;
2365 37112 dmisc32=d->misc32;
2366
3/4
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36629 times.
✓ Branch 3 taken 483 times.
37112 if (get_bit(quest_rules, qr_BROKEN_ATTRIBUTE_31_32))
2367 {
2368 36629 dmisc31 = dmisc32;
2369 36629 dmisc32 = 0;
2370 36629 }
2371 37112 spr_shadow=d->spr_shadow;
2372 37112 spr_death=d->spr_death;
2373 37112 spr_spawn=d->spr_spawn;
2374
2375
2/2
✓ Branch 0 taken 1521592 times.
✓ Branch 1 taken 37112 times.
1558704 for(int32_t i=0; i<edefLAST255; i++)
2376 1521592 defense[i]=d->defense[i];
2377
2378 37112 bgsfx=d->bgsfx;
2379 37112 hitsfx=d->hitsfx;
2380 37112 deadsfx=d->deadsfx;
2381 37112 bosspal=d->bosspal;
2382 37112 parent_script_UID = 0;
2383
2384 37112 frozentile = d->frozentile;
2385
2386 37112 frozencset = d->frozencset;
2387 37112 frozenclock = 0;
2388
2/2
✓ Branch 0 taken 371120 times.
✓ Branch 1 taken 37112 times.
408232 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
2389
2390
2/2
✓ Branch 0 taken 37112 times.
✓ Branch 1 taken 593792 times.
630904 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
2391 //firesfx = 0; //t.b.a -Z
2392 37112 isCore = true; //t.b.a
2393 37112 parentCore = 0; //t.b.a
2394
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2395
2396 37112 firesfx = d->firesfx;
2397
2/2
✓ Branch 0 taken 1187584 times.
✓ Branch 1 taken 37112 times.
1224696 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
2398
2/2
✓ Branch 0 taken 1187584 times.
✓ Branch 1 taken 37112 times.
1224696 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
2399
2400
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 script = (d->script >= 0) ? d->script : 0; //Dont assign invalid data.
2401 37112 waitdraw = 0;
2402
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 weaponscript = (d->weaponscript >= 0) ? d->weaponscript : 0; //Dont assign invalid data.
2403
2404
2/2
✓ Branch 0 taken 296896 times.
✓ Branch 1 taken 37112 times.
334008 for ( int32_t q = 0; q < 8; q++ )
2405 {
2406 296896 initD[q] = d->initD[q];
2407 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
2408 296896 weap_initiald[q] = d->weap_initiald[q];
2409 //al_trace("Guys.cpp: Assigning guy.initD[%d]: %d\n",q, d->initD.initD[q]);
2410 //al_trace("Guys.cpp: Assigning guy.initD[%d] from d->initD[%d]: %d\n",q,q, d->initD[q]);
2411 //al_trace("Guys.cpp: guy.initD[%d] is: %d\n",q, initD[q]);
2412 296896 }
2413
2/2
✓ Branch 0 taken 74224 times.
✓ Branch 1 taken 37112 times.
111336 for ( int32_t q = 0; q < 2; q++ )
2414 {
2415 74224 initA[q] = d->initA[q];
2416 74224 weap_initiala[q] = d->weap_initiala[q];
2417 74224 }
2418
2419 37112 stickclk = 0;
2420 37112 submerged = false;
2421 37112 ffcactivated = 0;
2422 37112 hitdir = -1;
2423 37112 dialogue_str = 0; //set by spawn flags.
2424 37112 editorflags = d->editorflags; //set by Enemy Editor
2425 //Set the drawing flag for this sprite.
2426
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
2427
2428
2429
2/2
✓ Branch 0 taken 7349 times.
✓ Branch 1 taken 29763 times.
37112 if(bosspal>-1)
2430 {
2431
1/2
✓ Branch 0 taken 7349 times.
✗ Branch 1 not taken.
7349 loadpalset(csBOSS,pSprite(bosspal));
2432 7349 }
2433
2434
2/2
✓ Branch 0 taken 21032 times.
✓ Branch 1 taken 16080 times.
37112 if(bgsfx>-1)
2435 {
2436
1/2
✓ Branch 0 taken 21032 times.
✗ Branch 1 not taken.
21032 cont_sfx(bgsfx);
2437 21032 }
2438
2439
3/4
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27523 times.
✓ Branch 3 taken 9589 times.
37112 if(get_bit(quest_rules,qr_NEWENEMYTILES))
2440 {
2441 27523 o_tile=d->e_tile;
2442 27523 frate = d->e_frate;
2443 27523 }
2444 else
2445 {
2446 9589 o_tile=d->tile;
2447 9589 frate = d->frate;
2448 }
2449
2450 37112 tile=0; //init to 0 here, but set it later.
2451
2452 37112 scripttile = -1;
2453 37112 scriptflip = -1;
2454 37112 do_animation = 1;
2455 37112 immortal = false;
2456 37112 noSlide = false;
2457 37112 deathexstate = -1;
2458
2459 37112 hashero=false;
2460
2461 // If they forgot the invisibility flag, here's another failsafe:
2462
4/4
✓ Branch 0 taken 2415 times.
✓ Branch 1 taken 34697 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 2321 times.
37112 if(o_tile==0 && family!=eeSPINTILE)
2463 2321 flags |= guy_invisible;
2464
2465 // step = d->step/100.0;
2466 // To preserve the odd step values for Keese & Gleeok heads. -L
2467
5/8
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4454 times.
✓ Branch 5 taken 32658 times.
✓ Branch 6 taken 4454 times.
✗ Branch 7 not taken.
37112 if(dstep==62.0) dstep+=0.5;
2468
5/8
✓ Branch 0 taken 32658 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 307 times.
✓ Branch 5 taken 32351 times.
✓ Branch 6 taken 307 times.
✗ Branch 7 not taken.
32658 else if(dstep==89) dstep-=1/9;
2469
2470
5/10
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37112 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 37112 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 37112 times.
✗ Branch 9 not taken.
37112 step = zslongToFix(dstep*100);
2471
2472
2473 37112 item_set = d->item_set;
2474 37112 grumble = d->grumble;
2475
2476
2/2
✓ Branch 0 taken 27903 times.
✓ Branch 1 taken 9209 times.
37112 if(frate == 0)
2477 9209 frate = 256;
2478
2479 37112 leader = itemguy = dying = scored = false;
2480 37112 canfreeze = count_enemy = true;
2481 37112 mainguy = !(flags & guy_doesntcount);
2482
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 dir = zc_oldrand()&3;
2483
2484 //2.6 Enemy Editor Hit and TIle Sizes
2485
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37112 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
2486 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
2487 // al_trace("Enemy txsz:%i\n", txsz);
2488
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37112 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
2489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37112 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
2490
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37112 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
2491
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37112 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
2492
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
2493
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
2494 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
2495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37112 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
2496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
37112 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
2497 {
2498 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
2499 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
2500 }
2501
2502
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37112 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
2503
2504 37112 SIZEflags = d->SIZEflags;
2505
2506
8/10
✓ Branch 0 taken 37024 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 37024 times.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 87 times.
37112 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
2507 1 wpn = 0;
2508
2509 //tile should never be 0 after init --Z (failsafe)
2510
4/6
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36064 times.
✓ Branch 5 taken 1048 times.
37112 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
2511
2512 //Moveflags; for gravity and pit interaction
2513 37112 moveflags = d->moveflags;
2514
3/4
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31774 times.
✓ Branch 3 taken 5338 times.
37112 if(!can_pitfall(false))
2515 {
2516 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
2517 5338 moveflags &= ~FLAG_CAN_PITFALL;
2518 5338 moveflags &= ~FLAG_CAN_WATERDROWN;
2519 5338 }
2520
2521
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 shieldCanBlock = get_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG)?true:false;
2522 37112 }
2523
2524 //base clone constructor
2525
2526 enemy::enemy(enemy const & other, bool new_script_uid, bool clear_parent_script_UID):
2527 //Struct Element Type Purpose
2528 sprite(other),
2529 //x(other.x), //int32_t
2530 //y(other.y), //int32_t
2531 //id(other.id), //int32_t
2532 //clk(other.clk), //int32_t
2533 floor_y(other.floor_y), //int32_t
2534 fading(other.fading), //int32_t
2535 //misc(other.misc), //int32_t
2536 clk2(other.clk2), //int32_t
2537 clk3(other.clk3), //int32_t
2538 stunclk(other.stunclk), //int32_t
2539 hclk(other.hclk), //int32_t
2540 sclk(other.sclk), //int32_t
2541 superman(other.superman), //int32_t
2542 //grumble(other.grumble), //int32_t
2543 movestatus(other.movestatus), //int32_t
2544 posframe(other.posframe), //int32_t
2545 timer(other.timer), //int32_t
2546 ox(other.ox), //int32_t
2547 oy(other.oy), //int32_t
2548 //yofs(other.yofs), //int32_t
2549 did_armos(other.did_armos), //int32_t
2550 script_spawned(other.script_spawned), //int32_t
2551 d(other.d), //int32_t
2552 hp(other.hp), //int32_t
2553 starting_hp(other.starting_hp), //int32_t
2554 //flags(other.flags), //int32_t
2555
2556 flags2(other.flags2), //int32_t
2557 s_tile(other.s_tile), //int32_t
2558 family(other.family), //int32_t
2559 dcset(other.dcset), //int32_t
2560 //cs(other.cs), //int32_t
2561 anim(other.anim), //int32_t
2562 dp(other.dp), //int32_t
2563 wdp(other.wdp), //int32_t
2564 wpnsprite(other.wpnsprite), //int32_t
2565 rate(other.rate), //int32_t
2566 hrate(other.hrate), //int32_t
2567 dstep(other.dstep), //int32_t
2568
2569 homing(other.homing), //int32_t
2570 dmisc1(other.dmisc1), //int32_t
2571 dmisc2(other.dmisc2), //int32_t
2572 dmisc3(other.dmisc3), //int32_t
2573 dmisc4(other.dmisc4), //int32_t
2574 dmisc5(other.dmisc5), //int32_t
2575 dmisc6(other.dmisc6), //int32_t
2576 dmisc7(other.dmisc7), //int32_t
2577 dmisc8(other.dmisc8), //int32_t
2578 dmisc9(other.dmisc9), //int32_t
2579 dmisc10(other.dmisc10), //int32_t
2580 dmisc11(other.dmisc11), //int32_t
2581 dmisc12(other.dmisc12), //int32_t
2582 dmisc13(other.dmisc13), //int32_t
2583 dmisc14(other.dmisc14), //int32_t
2584 dmisc15(other.dmisc15), //int32_t
2585 dmisc16(other.dmisc16), //int32_t
2586 dmisc17(other.dmisc17), //int32_t
2587 dmisc18(other.dmisc18), //int32_t
2588 dmisc19(other.dmisc19), //int32_t
2589 dmisc20(other.dmisc20), //int32_t
2590 dmisc21(other.dmisc21), //int32_t
2591 dmisc22(other.dmisc22), //int32_t
2592 dmisc23(other.dmisc23), //int32_t
2593 dmisc24(other.dmisc24), //int32_t
2594 dmisc25(other.dmisc25), //int32_t
2595 dmisc26(other.dmisc26), //int32_t
2596 dmisc27(other.dmisc27), //int32_t
2597 dmisc28(other.dmisc28), //int32_t
2598 dmisc29(other.dmisc29), //int32_t
2599 dmisc30(other.dmisc30), //int32_t
2600 dmisc31(other.dmisc31), //int32_t
2601 dmisc32(other.dmisc32), //int32_t
2602 bgsfx(other.bgsfx), //int32_t
2603 hitsfx(other.hitsfx), //int32_t
2604 deadsfx(other.deadsfx), //int32_t
2605 bosspal(other.bosspal), //int32_t
2606 parent_script_UID(other.parent_script_UID), //int32_t
2607 frozentile(other.frozentile), //int32_t
2608 frozencset(other.frozencset), //int32_t
2609 frozenclock(other.frozenclock), //int32_t
2610 isCore(other.isCore), //int32_t
2611 parentCore(other.parentCore), //int32_t
2612 script_UID(other.script_UID), //int32_t
2613 firesfx(other.firesfx), //int32_t
2614 //script(other.script), //int32_t
2615 //waitdraw(other.waitdraw), //int32_t
2616 weaponscript(other.weaponscript), //int32_t
2617 stickclk(other.stickclk), //int32_t
2618 hitdir(other.hitdir), //int32_t
2619 submerged(other.submerged), //int32_t
2620 ffcactivated(other.ffcactivated), //word
2621
2622 dialogue_str(other.dialogue_str), //int32_t
2623 editorflags(other.editorflags), //int32_t
2624 //drawflags(other.drawflags), //int32_t
2625 o_tile(other.o_tile), //int32_t
2626 frate(other.frate), //int32_t
2627 //tile(other.tile), //int32_t
2628 //scripttile(other.scripttile), //int32_t
2629 //scriptflip(other.scriptflip), //int32_t
2630 //do_animation(other.do_animation), //int32_t
2631 immortal(other.immortal), //bool
2632 noSlide(other.noSlide), //bool
2633 deathexstate(other.deathexstate), //int32_t
2634 flags(other.flags), //int32_t
2635 step(other.step), //int32_t
2636
2637 item_set(other.item_set), //int32_t
2638 grumble(other.grumble), //int32_t
2639 leader(other.leader), //int32_t
2640 itemguy(other.itemguy), //int32_t
2641 dying(other.dying), //int32_t
2642 scored(other.scored), //int32_t
2643 //canfreeze(other.canfreeze), //int32_t
2644 count_enemy(other.count_enemy), //int32_t
2645 mainguy(other.mainguy), //int32_t
2646 //dir(other.dir), //int32_t
2647
2648 //txsz(other.txsz), //int32_t
2649 //tysz(other.tysz), //int32_t
2650 //hxsz(other.hxsz), //int32_t
2651 //hysz(other.hysz), //int32_t
2652 //hzsz(other.hzsz), //int32_t
2653 //hxofs(other.hxofs), //int32_t
2654 //hxofs(other.hxofs), //int32_t
2655 //xofs(other.xofs), //int32_t
2656 //yofs(other.yofs), //int32_t
2657 //hzofs(other.hzofs), //int32_t
2658 //zofs(other.zofs), //int32_t
2659
2660 wpn(other.wpn), //int32_t
2661 SIZEflags(other.SIZEflags), //int32_t
2662 hashero(other.hashero)
2663
2664 {
2665
2666 //arrays
2667
2668 if(other.scrmem)
2669 {
2670 alloc_scriptmem();
2671 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2672
2673 scrmem->scriptData = other.scrmem->scriptData;
2674 }
2675 else scrmem = NULL;
2676 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2677 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2678
2679 for(int32_t i=0; i<edefLAST255; i++)
2680 defense[i]=other.defense[i];
2681 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2682 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2683
2684 if(new_script_uid)
2685 {
2686 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2687 }
2688 if(clear_parent_script_UID)
2689 {
2690 parent_script_UID = 0;
2691 }
2692 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2693 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2694
2695 for ( int32_t q = 0; q < 8; q++ )
2696 {
2697 initD[q] = other.initD[q];
2698 weap_initiald[q] = other.weap_initiald[q];
2699 }
2700 for ( int32_t q = 0; q < 2; q++ )
2701 {
2702 initA[q] = other.initA[q];
2703 weap_initiala[q] = other.weap_initiala[q];
2704 }
2705 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
2706 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
2707 // al_trace("Enemy txsz:%i\n", txsz);
2708 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
2709 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
2710 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
2711 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
2712 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
2713 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
2714 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
2715 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
2716 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
2717 {
2718 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
2719 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
2720 }
2721
2722 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
2723
2724
2725
2726
2727 }
2728
2729
2730 489 int32_t enemy::getScriptUID() { return script_UID; }
2731 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
2732 37093 enemy::~enemy()
2733 37093 {
2734
2/4
✓ Branch 0 taken 37093 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37093 times.
✗ Branch 3 not taken.
37093 FFCore.deallocateAllArrays(SCRIPT_NPC, getUID());
2735
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 37090 times.
37093 if(hashero)
2736 {
2737
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 Hero.setEaten(0);
2738 3 hashero=false;
2739 3 }
2740 37093 }
2741
2742
2743 bool enemy::is_move_paused()
2744 {
2745 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
2746 }
2747
2748 11304 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
2749 {
2750 11304 int32_t yg = (special==spw_floater)?8:0;
2751 11304 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
2752 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
2753
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 if(input_x == -1000)
2754 input_x = dx;
2755
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 if(input_y == -1000)
2756 input_y = dy;
2757
2758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
22608 if(!(moveflags & FLAG_IGNORE_SCREENEDGE)
2759
3/6
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11304 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11304 times.
11304 && (input_x<16-nb || input_y<zc_max(16-yg-nb,0)
2760
2/4
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
11304 || input_x>=240+nb-hxsz || input_y>=160+nb-hysz))
2761 return true;
2762
2763
3/6
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11304 times.
✗ Branch 5 not taken.
11304 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
2764 {
2765 if(ispitfall(dx,dy))
2766 return true;
2767 }
2768
2769 11304 bool flying = false;
2770 11304 bool cansolid = false;
2771
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 if(moveflags & FLAG_IGNORE_SOLIDITY)
2772 cansolid = true;
2773
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11304 switch(special)
2774 {
2775 case spw_clipbottomright:
2776 if(dy>=128 || dx>=208) return true;
2777 break;
2778 case spw_clipright:
2779 break; //if(input_x>=208) return true; break;
2780
2781 case spw_wizzrobe: // fall through
2782 case spw_floater: // Special case for fliers and wizzrobes - hack!
2783 {
2784 if(isdungeon() && !(moveflags & FLAG_IGNORE_SCREENEDGE))
2785 {
2786 if(dy < 32-yg || dy >= 144) return true;
2787 if(dx < 32 || dx >= 224) return true;
2788 }
2789 if(!(moveflags & FLAG_IGNORE_BLOCKFLAGS) && flyerblocked(dx, dy, special, kb))
2790 return true;
2791 cansolid = true;
2792 flying = true;
2793 }
2794 }
2795
2796 11304 dx &= ~7;
2797 11304 dy &= ~7;
2798
2799
3/6
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11304 times.
✗ Branch 5 not taken.
11304 if(!flying && !(moveflags & FLAG_IGNORE_BLOCKFLAGS) && groundblocked(dx,dy,kb)) return true;
2800
2801
4/8
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11304 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11304 times.
11304 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
2802 return false;
2803 //_walkflag code
2804 mapscr *s1, *s2;
2805 11304 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
2806 11304 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
2807
2808 11304 int32_t cpos=(dx>>4)+(dy&0xF0);
2809
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✓ Branch 2 taken 8964 times.
✓ Branch 3 taken 2340 times.
11304 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
2810 11304 newcombo const& c = combobuf[ci];
2811 11304 newcombo const& c1 = combobuf[ci1];
2812 11304 newcombo const& c2 = combobuf[ci2];
2813
2814 11304 int32_t b=1;
2815
2/2
✓ Branch 0 taken 5447 times.
✓ Branch 1 taken 5857 times.
11304 if(dx&8) b<<=2;
2816
2/2
✓ Branch 0 taken 5885 times.
✓ Branch 1 taken 5419 times.
11304 if(dy&8) b<<=1;
2817
2818 #define iwtr(cmb, x, y, shallow) \
2819 (shallow \
2820 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
2821 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
2822 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
2823 11304 bool wtr = iwtr(ci, dx, dy, false);
2824
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 bool shwtr = iwtr(ci, dx, dy, true);
2825 11304 bool pit = ispitfall(dx,dy);
2826
2827
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
11304 bool canwtr = (moveflags & FLAG_CAN_WATERWALK) || ((moveflags & FLAG_CAN_WATERDROWN) && kb);
2828
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11304 times.
11304 bool canpit = (moveflags & FLAG_CAN_PITWALK) || ((moveflags & FLAG_CAN_PITFALL) && kb);
2829 11304 bool needwtr = (moveflags & FLAG_ONLY_WATERWALK);
2830 11304 bool needshwtr = (moveflags & FLAG_ONLY_SHALLOW_WATERWALK);
2831 11304 bool needpit = (moveflags & FLAG_ONLY_PITWALK);
2832
2833 11304 int32_t cwalkflag = c.walk & 0xF;
2834
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11304 if (c.type == cBRIDGE && get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
2835
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 if (s1)
2836 {
2837 if (c1.type == cBRIDGE)
2838 {
2839 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
2840 {
2841 int efflag = (c1.walk & 0xF0)>>4;
2842 int newsolid = (c1.walk & 0xF);
2843 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
2844 }
2845 else cwalkflag &= c1.walk;
2846 }
2847 else cwalkflag |= c1.walk & 0xF;
2848 }
2849
2/2
✓ Branch 0 taken 2340 times.
✓ Branch 1 taken 8964 times.
11304 if (s2)
2850 {
2851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8964 times.
8964 if (c2.type == cBRIDGE)
2852 {
2853 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
2854 {
2855 int efflag = (c2.walk & 0xF0)>>4;
2856 int newsolid = (c2.walk & 0xF);
2857 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
2858 }
2859 else cwalkflag &= c2.walk;
2860 }
2861 8964 else cwalkflag |= c2.walk & 0xF;
2862 8964 }
2863 11304 bool solid = cwalkflag & b;
2864
3/4
✓ Branch 0 taken 1437 times.
✓ Branch 1 taken 9867 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1437 times.
11304 if (solid && !cansolid) return true;
2865
3/6
✓ Branch 0 taken 9867 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9867 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9867 times.
9867 if(needwtr || needshwtr || needpit)
2866 {
2867 bool ret = true;
2868 if (needwtr && wtr) ret = false;
2869 else if (needshwtr && shwtr) ret = false;
2870 else if (needpit && pit) ret = false;
2871 return ret;
2872 }
2873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9867 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9867 else if(wtr && !canwtr)
2874 return true;
2875
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9867 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9867 else if(pit && !canpit)
2876 return true;
2877
2878 9867 return false;
2879 11304 }
2880
2881 4726 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
2882 {
2883
3/4
✓ Branch 0 taken 3330 times.
✓ Branch 1 taken 1396 times.
✓ Branch 2 taken 3330 times.
✗ Branch 3 not taken.
4726 if(!(dx || dy)) return true;
2884 4726 zfix bx = x+hxofs, by = y+hyofs; //left/top
2885 4726 zfix rx = bx+hxsz-1, ry = by+hysz-1; //right/bottom
2886
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4726 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4726 if(!ign_sv && dy < 0) //check gravity
2887 {
2888 if((moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
2889 return false;
2890 }
2891
2892
3/4
✓ Branch 0 taken 1396 times.
✓ Branch 1 taken 3330 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1396 times.
4726 if(dx && !dy)
2893 {
2894
2/2
✓ Branch 0 taken 777 times.
✓ Branch 1 taken 619 times.
1396 if(dx < 0)
2895 {
2896
2/4
✓ Branch 0 taken 777 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 777 times.
777 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
2897 777 int32_t tx = (bx+dx).getFloor();
2898
2/2
✓ Branch 0 taken 1554 times.
✓ Branch 1 taken 777 times.
2331 for(zfix ty = 0; by+ty < ry; ty += 8)
2899 {
2900
1/2
✓ Branch 0 taken 1554 times.
✗ Branch 1 not taken.
1554 if(scr_walkflag(tx, by+ty, special, left, bx, by, kb))
2901 return false;
2902 1554 }
2903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777 times.
777 if(scr_walkflag(tx, ry, special, left, bx, by, kb))
2904 return false;
2905 777 }
2906 else
2907 {
2908 619 int32_t tx = (rx+dx).getCeil();
2909
2/2
✓ Branch 0 taken 1238 times.
✓ Branch 1 taken 619 times.
1857 for(zfix ty = 0; by+ty < ry; ty += 8)
2910 {
2911
1/2
✓ Branch 0 taken 1238 times.
✗ Branch 1 not taken.
1238 if(scr_walkflag(tx, by+ty, special, right, bx, by, kb))
2912 return false;
2913 1238 }
2914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
619 if(scr_walkflag(tx, ry, special, right, bx, by, kb))
2915 return false;
2916 }
2917 1396 }
2918
2/4
✓ Branch 0 taken 3330 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3330 times.
3330 else if(dy && !dx)
2919 {
2920
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 1535 times.
3330 if(dy < 0)
2921 {
2922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1795 times.
1795 special = (special==spw_clipbottomright)?spw_none:special;
2923 1795 int32_t ty = (by+dy).getFloor();
2924
2/2
✓ Branch 0 taken 3590 times.
✓ Branch 1 taken 1795 times.
5385 for(zfix tx = 0; bx+tx < rx; tx += 8)
2925 {
2926
1/2
✓ Branch 0 taken 3590 times.
✗ Branch 1 not taken.
3590 if(scr_walkflag(bx+tx, ty, special, up, bx, by, kb))
2927 return false;
2928 3590 }
2929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1795 times.
1795 if(scr_walkflag(rx, ty, special, up, bx, by, kb))
2930 return false;
2931 1795 }
2932 else
2933 {
2934 1535 int32_t ty = (ry+dy).getCeil();
2935
2/2
✓ Branch 0 taken 1633 times.
✓ Branch 1 taken 98 times.
1731 for(zfix tx = 0; bx+tx < rx; tx += 8)
2936 {
2937
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 1437 times.
1633 if(scr_walkflag(bx+tx, ty, special, down, bx, by, kb))
2938 1437 return false;
2939 196 }
2940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(scr_walkflag(rx, ty, special, down, bx, by, kb))
2941 return false;
2942 }
2943 1893 }
2944 else
2945 {
2946 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
2947 }
2948 3289 return true;
2949 4726 }
2950
2951 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
2952 {
2953 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
2954 zfix rx = bx+hxsz-1, ry = by+hysz-1; //right/bottom
2955
2956 for(zfix ty = 0; by+ty < ry; ty += 8)
2957 {
2958 for(zfix tx = 0; bx+tx < rx; tx += 8)
2959 {
2960 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
2961 return false;
2962 }
2963 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
2964 return false;
2965 }
2966 for(zfix tx = 0; bx+tx < rx; tx += 8)
2967 {
2968 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
2969 return false;
2970 }
2971 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
2972 return false;
2973 return true;
2974 }
2975
2976 3427 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
2977 {
2978 3427 bool ret = true;
2979
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3427 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3427 if(!ign_sv && dy < 0 && (moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
2980 dy = 0;
2981
4/4
✓ Branch 0 taken 3547 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3427 times.
✓ Branch 3 taken 179 times.
3606 while(abs(dx) > 8 || abs(dy) > 8)
2982 {
2983
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 139 times.
179 if(abs(dx) > abs(dy))
2984 {
2985 40 int32_t tdx = dx.sign() * 8;
2986
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(movexy(tdx, 0, special, kb, ign_sv))
2987 40 dx -= tdx;
2988 else
2989 {
2990 dx = tdx;
2991 ret = false;
2992 }
2993 40 }
2994 else
2995 {
2996 139 int32_t tdy = dy.sign() * 8;
2997
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 136 times.
139 if(movexy(0, tdy, special, kb, ign_sv))
2998 3 dy -= tdy;
2999 else
3000 {
3001 136 dy = tdy;
3002 136 ret = false;
3003 }
3004 }
3005 }
3006
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 1396 times.
3427 if(dx)
3007 {
3008
1/2
✓ Branch 0 taken 1396 times.
✗ Branch 1 not taken.
1396 if(scr_canmove(dx, 0, special, kb, ign_sv))
3009 1396 x += dx;
3010 else
3011 {
3012 ret = false;
3013 int32_t xsign = dx.sign();
3014 while(scr_canmove(xsign, 0, special, kb, ign_sv))
3015 {
3016 x += xsign;
3017 dx -= xsign;
3018 }
3019 if(scr_canmove(dx.decsign(), 0, special, kb, ign_sv)) //can move 0.0001 to 0.9999 px in this direction
3020 {
3021 if(dx > 0)
3022 x.doCeil();
3023 else x.doFloor();
3024 }
3025 }
3026 1396 }
3027
2/2
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 2372 times.
3427 if(dy)
3028 {
3029
2/2
✓ Branch 0 taken 1893 times.
✓ Branch 1 taken 479 times.
2372 if(scr_canmove(0, dy, special, kb, ign_sv))
3030 1893 y += dy;
3031 else
3032 {
3033 479 ret = false;
3034 479 int32_t ysign = dy.sign();
3035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 479 times.
479 while(scr_canmove(0, ysign, special, kb, ign_sv))
3036 {
3037 y += ysign;
3038 dy -= ysign;
3039 }
3040
1/2
✓ Branch 0 taken 479 times.
✗ Branch 1 not taken.
479 if(scr_canmove(0, dy.decsign(), special, kb, ign_sv)) //can move 0.0001 to 0.9999 px in this direction
3041 {
3042 if(dy > 0)
3043 y.doCeil();
3044 else y.doFloor();
3045 }
3046 }
3047 2372 }
3048 3427 return ret;
3049 }
3050
3051 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb)
3052 {
3053 zfix diagrate = zslongToFix(7071);
3054 switch(NORMAL_DIR(dir))
3055 {
3056 case up:
3057 return movexy(0, -px, special, kb);
3058 case down:
3059 return movexy(0, px, special, kb);
3060 case left:
3061 return movexy(-px, 0, special, kb);
3062 case right:
3063 return movexy(px, 0, special, kb);
3064 case r_up:
3065 return movexy(px*diagrate, -px*diagrate, special, kb);
3066 case r_down:
3067 return movexy(px*diagrate, px*diagrate, special, kb);
3068 case l_up:
3069 return movexy(-px*diagrate, -px*diagrate, special, kb);
3070 case l_down:
3071 return movexy(-px*diagrate, px*diagrate, special, kb);
3072 }
3073 return false;
3074 }
3075
3076 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
3077 {
3078 double v = degrees.getFloat() * PI / 180.0;
3079 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
3080 return movexy(dx, dy, special, kb);
3081 }
3082
3083 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
3084 {
3085 zfix tx = x, ty = y;
3086 bool ret = movexy(dx, dy, special, kb);
3087 x = tx;
3088 y = ty;
3089 return ret;
3090 }
3091 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
3092 {
3093 zfix tx = x, ty = y;
3094 bool ret = moveDir(dir, px, special, kb);
3095 x = tx;
3096 y = ty;
3097 return ret;
3098 }
3099 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
3100 {
3101 zfix tx = x, ty = y;
3102 bool ret = moveAtAngle(degrees, px, special, kb);
3103 x = tx;
3104 y = ty;
3105 return ret;
3106 }
3107
3108 // Handle pitfalls
3109 15718990 bool enemy::do_falling(int32_t index)
3110 {
3111
2/2
✓ Branch 0 taken 15718848 times.
✓ Branch 1 taken 142 times.
15718990 if(fallclk > 0)
3112 {
3113
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
142 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
3114
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 4 times.
142 if(!--fallclk)
3115 {
3116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(immortal) //Keep alive forever
3117 ++fallclk; //force another frame of falling.... forever.
3118
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(dying) //Give 1 frame for script revival
3119 {
3120
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags&guy_neverret)
3121 never_return(index);
3122
3123
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(leader)
3124 kill_em_all();
3125
3126 //leave_item(); //Don't drop items in pits!
3127 2 stop_bgsfx(index);
3128 2 return true;
3129 }
3130 else
3131 {
3132 2 try_death(true); //Force death
3133 2 ++fallclk; //force another frame of falling
3134 }
3135 2 }
3136
3137 140 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
3138 140 cs = spr.csets & 0xF;
3139
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t fr = spr.frames ? spr.frames : 1;
3140
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t spd = spr.speed ? spr.speed : 1;
3141 140 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
3142
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 82 times.
140 tile = spr.tile + zc_min(animclk / spd, fr-1);
3143 140 }
3144 15718988 return false;
3145 15718990 }
3146
3147 // Handle drowning in water
3148 15718848 bool enemy::do_drowning(int32_t index)
3149 {
3150
1/2
✓ Branch 0 taken 15718848 times.
✗ Branch 1 not taken.
15718848 if(drownclk > 0)
3151 {
3152 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
3153 //!TODO: Drown SFX
3154 if(!--drownclk)
3155 {
3156 if(immortal) //Keep alive forever
3157 ++drownclk; //force another frame of falling.... forever.
3158 else if(dying) //Give 1 frame for script revival
3159 {
3160 if(flags&guy_neverret)
3161 never_return(index);
3162
3163 if(leader)
3164 kill_em_all();
3165
3166 //leave_item(); //Don't drop items in pits!
3167 stop_bgsfx(index);
3168 return true;
3169 }
3170 else
3171 {
3172 try_death(true); //Force death
3173 ++drownclk; //force another frame of falling
3174 }
3175 }
3176
3177 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
3178 {
3179 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
3180 cs = spr.csets & 0xF;
3181 int32_t fr = spr.frames ? spr.frames : 1;
3182 int32_t spd = spr.speed ? spr.speed : 1;
3183 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
3184 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
3185 }
3186 else
3187 {
3188 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
3189 cs = spr.csets & 0xF;
3190 int32_t fr = spr.frames ? spr.frames : 1;
3191 int32_t spd = spr.speed ? spr.speed : 1;
3192 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
3193 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
3194 }
3195 }
3196 15718848 return false;
3197 15718848 }
3198
3199 // Supplemental animation code that all derived classes should call
3200 // as a return value for animate().
3201 // Handles the death animation and returns true when enemy is finished.
3202 16017063 bool enemy::Dead(int32_t index)
3203 {
3204
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 16015234 times.
16017063 if(immortal)
3205 {
3206 1829 dying = false;
3207 1829 return false;
3208 }
3209
2/2
✓ Branch 0 taken 322055 times.
✓ Branch 1 taken 15693179 times.
16015234 if(dying)
3210 {
3211
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 322054 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
322055 if(deathexstate > -1 && deathexstate < 32)
3212 {
3213 1 setxmapflag(1<<deathexstate);
3214 1 deathexstate = -1;
3215 1 }
3216 322055 --clk2;
3217
3218
4/4
✓ Branch 0 taken 317360 times.
✓ Branch 1 taken 4695 times.
✓ Branch 2 taken 16217 times.
✓ Branch 3 taken 501 times.
322055 if((get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
3219
2/2
✓ Branch 0 taken 16718 times.
✓ Branch 1 taken 300642 times.
317360 && hp>-1000) // not killed by ringleader
3220 16217 death_sfx();
3221
3222
2/2
✓ Branch 0 taken 305113 times.
✓ Branch 1 taken 16942 times.
322055 if(clk2==0)
3223 {
3224
2/2
✓ Branch 0 taken 16602 times.
✓ Branch 1 taken 340 times.
16942 if(flags&guy_neverret)
3225 340 never_return(index);
3226
3227
2/2
✓ Branch 0 taken 16889 times.
✓ Branch 1 taken 53 times.
16942 if(leader)
3228 53 kill_em_all();
3229
3230 16942 leave_item();
3231 16942 }
3232
3233 322055 stop_bgsfx(index);
3234 322055 return (clk2==0);
3235 }
3236
3237 15693179 return false;
3238 16017063 }
3239
3240 // Basic animation code that all derived classes should call.
3241 // The one with an index is the one that is called by
3242 // the guys sprite list; index is the enemy's index in the list.
3243 16368790 bool enemy::animate(int32_t index)
3244 {
3245
2/2
✓ Branch 0 taken 1403315 times.
✓ Branch 1 taken 14965475 times.
16368790 if(sclk <= 0) hitdir = -1;
3246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15413358 times.
16368790 if(switch_hooked)
3247 {
3248 if(get_bit(quest_rules, qr_SWITCHOBJ_RUN_SCRIPT))
3249 {
3250 //Run its script
3251 if (run_script(MODE_NORMAL)==RUNSCRIPT_SELFDELETE)
3252 {
3253 return 0; //Avoid NULLPO if this object deleted itself
3254 }
3255 }
3256 return false;
3257 }
3258
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 15413356 times.
15413358 if(do_falling(index)) return true;
3259
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 15413216 times.
15413356 else if(fallclk)
3260 {
3261 //clks
3262
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 60 times.
140 if(hclk>0)
3263 60 --hclk;
3264
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(stunclk>0)
3265 --stunclk;
3266
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( frozenclock > 0 )
3267 --frozenclock;
3268
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(hashero)
3269 {
3270 Hero.setX(x);
3271 Hero.setY(y);
3272 Hero.fallCombo = fallCombo;
3273 Hero.fallclk = fallclk;
3274 hashero = false; //Let Hero go if falling
3275 }
3276 140 run_script(MODE_NORMAL);
3277 140 return false;
3278 }
3279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15413216 times.
15413216 if(do_drowning(index)) return true;
3280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15413216 times.
15413216 else if(drownclk)
3281 {
3282 //clks
3283 if(hclk>0)
3284 --hclk;
3285 if(stunclk>0)
3286 --stunclk;
3287 if ( frozenclock > 0 )
3288 --frozenclock;
3289 if(hashero)
3290 {
3291 Hero.setX(x);
3292 Hero.setY(y);
3293 Hero.drownclk = drownclk;
3294 hashero = false; //Let Hero go if falling
3295 }
3296 run_script(MODE_NORMAL);
3297 return false;
3298 }
3299 15413216 int32_t nx = real_x(x);
3300 15413216 int32_t ny = real_y(y);
3301
3302
4/4
✓ Branch 0 taken 11485436 times.
✓ Branch 1 taken 3927780 times.
✓ Branch 2 taken 2571878 times.
✓ Branch 3 taken 12256256 times.
15413216 if(ox!=nx || oy!=ny)
3303 {
3304 6499658 posframe=(posframe+1)%(get_bit(quest_rules,qr_NEWENEMYTILES)?4:2);
3305 6499658 }
3306
3307 18755914 ox = nx;
3308 18755914 oy = ny;
3309
3310 // Maybe they fell off the bottom in sideview, or were moved by a script.
3311
3312 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
3313
2/2
✓ Branch 0 taken 3038895 times.
✓ Branch 1 taken 15717019 times.
18755914 if ( immortal )
3314 {
3315 //skip, as it can go out of bounds, from immortality
3316 3038895 }
3317
2/6
✓ Branch 0 taken 15717019 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15717019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15717019 else if ( (moveflags & FLAG_IGNORE_SCREENEDGE) || (( (get_bit(quest_rules, qr_OUTOFBOUNDSENEMIES)) != (editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
3318 {
3319 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
3320 }
3321
9/10
✓ Branch 0 taken 15296626 times.
✓ Branch 1 taken 420393 times.
✓ Branch 2 taken 15716690 times.
✓ Branch 3 taken 329 times.
✓ Branch 4 taken 15716645 times.
✓ Branch 5 taken 45 times.
✓ Branch 6 taken 15716645 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✓ Branch 9 taken 15716609 times.
15717019 else if ( (OUTOFBOUNDS) )
3322 {
3323 410 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
3324 410 }
3325 //fall down
3326
6/6
✓ Branch 0 taken 9064566 times.
✓ Branch 1 taken 9479844 times.
✓ Branch 2 taken 6495320 times.
✓ Branch 3 taken 12049090 times.
✓ Branch 4 taken 293418 times.
✓ Branch 5 taken 6201902 times.
18755914 if((enemycanfall(id) || (moveflags & FLAG_OBEYS_GRAV) )&& fading != fade_flicker && clk>=0)
3327 {
3328
2/2
✓ Branch 0 taken 327574 times.
✓ Branch 1 taken 5874328 times.
6201902 if(isSideViewGravity())
3329 {
3330
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 24000 times.
327574 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
3331 {
3332
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
3333 {
3334 127235 bool willHitSVPlatform = false;
3335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH)?hxsz:16;
3336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT)?hysz:16;
3337
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
3338 {
3339
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
3340 {
3341 willHitSVPlatform = true;
3342 break;
3343 }
3344 127235 }
3345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
3346 {
3347 y+=fall/100;
3348 //y-=int32_t(y)%16; //Fix to top of SV Ladder
3349 do_fix(y, 16); //Fix to top of SV Ladder
3350 fall = 0;
3351 }
3352 else
3353 {
3354 127235 y+=fall/100;
3355
2/2
✓ Branch 0 taken 17808 times.
✓ Branch 1 taken 109427 times.
127235 if(fall <= (int32_t)zinit.terminalv)
3356 109427 fall += (zinit.gravity2/100);
3357 }
3358 127235 }
3359 else
3360 {
3361
2/2
✓ Branch 0 taken 176072 times.
✓ Branch 1 taken 267 times.
176339 if(fall!=0) // Only fix pos once
3362 {
3363 //y-=(int32_t)y%8; // Fix position
3364 267 do_fix(y, 8); //Fix position
3365 267 }
3366
3367 176339 fall = 0;
3368 }
3369 303574 }
3370 else
3371 {
3372
2/2
✓ Branch 0 taken 22585 times.
✓ Branch 1 taken 1415 times.
24000 if(isOnSideviewPlatform())
3373 22585 fall = 0;
3374 else
3375 {
3376 1415 zfix fall_amnt = fall/100;
3377 1415 bool hit = false;
3378
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 1819 times.
3201 while(fall_amnt >= 1)
3379 {
3380 1819 --fall_amnt;
3381 1819 ++y;
3382
2/2
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 33 times.
1819 if(isOnSideviewPlatform())
3383 {
3384 33 y = y.getInt();
3385 33 fall_amnt = 0;
3386 33 hit = true;
3387 33 break;
3388 }
3389 }
3390
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 1302 times.
1415 if(fall_amnt > 0)
3391 1302 y += fall_amnt;
3392
1/2
✓ Branch 0 taken 1415 times.
✗ Branch 1 not taken.
1415 if(fall_amnt < 0)
3393 {
3394 if(!movexy(0,fall_amnt,spw_none))
3395 hit = true;
3396 }
3397
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1382 times.
1415 if(hit)
3398 33 fall = 0;
3399
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1105 times.
1382 else if(fall <= (int32_t)zinit.terminalv)
3400 1105 fall += (zinit.gravity2/100);
3401 }
3402 }
3403 327574 }
3404 else
3405 {
3406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5874328 times.
5874328 if (!(moveflags & FLAG_NO_FAKE_Z))
3407 {
3408
2/2
✓ Branch 0 taken 2982330 times.
✓ Branch 1 taken 2891998 times.
5874328 if(fakefall!=0)
3409 2891998 fakez-=(fakefall/100);
3410
3411
2/2
✓ Branch 0 taken 2891998 times.
✓ Branch 1 taken 2982330 times.
5874328 if(fakez<0)
3412 2891998 fakez = fakefall = 0;
3413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2982330 times.
2982330 else if(fakefall <= (int32_t)zinit.terminalv)
3414 2982330 fakefall += (zinit.gravity2/100);
3415
3416
5/6
✓ Branch 0 taken 5874328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2982330 times.
✓ Branch 3 taken 2891998 times.
✓ Branch 4 taken 2899012 times.
✓ Branch 5 taken 83318 times.
5874328 if (fakez<=0 && fakefall > 0 && !get_bit(quest_rules, qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
3417 5874328 }
3418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5874328 times.
5874328 if (!(moveflags & FLAG_NO_REAL_Z))
3419 {
3420
2/2
✓ Branch 0 taken 2989696 times.
✓ Branch 1 taken 2884632 times.
5874328 if(fall!=0)
3421 2884632 z-=(fall/100);
3422
3423
2/2
✓ Branch 0 taken 2878808 times.
✓ Branch 1 taken 2995520 times.
5874328 if(z<0)
3424 2878808 z = fall = 0;
3425
2/2
✓ Branch 0 taken 4644 times.
✓ Branch 1 taken 2990876 times.
2995520 else if(fall <= (int32_t)zinit.terminalv)
3426 2990876 fall += (zinit.gravity2/100);
3427
3428
6/6
✓ Branch 0 taken 5868407 times.
✓ Branch 1 taken 5921 times.
✓ Branch 2 taken 2989599 times.
✓ Branch 3 taken 2878808 times.
✓ Branch 4 taken 2906281 times.
✓ Branch 5 taken 83318 times.
5874328 if (z<=0 && fall > 0 && !get_bit(quest_rules, qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
3429 5874328 }
3430
3431 }
3432 6201902 }
3433
4/4
✓ Branch 0 taken 15298455 times.
✓ Branch 1 taken 3245955 times.
✓ Branch 2 taken 7008588 times.
✓ Branch 3 taken 16341529 times.
18544410 if(!isSideViewGravity() && (moveflags & FLAG_CAN_PITFALL))
3434 {
3435
8/10
✓ Branch 0 taken 5454951 times.
✓ Branch 1 taken 10886578 times.
✓ Branch 2 taken 5447966 times.
✓ Branch 3 taken 6985 times.
✓ Branch 4 taken 5447966 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5454951 times.
✓ Branch 8 taken 5447966 times.
✓ Branch 9 taken 5447966 times.
16341529 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
3436 {
3437 5447966 fallCombo = check_pits();
3438 5447966 }
3439 27237461 }
3440
3/4
✓ Branch 0 taken 15298455 times.
✓ Branch 1 taken 420393 times.
✓ Branch 2 taken 15298455 times.
✗ Branch 3 not taken.
15718848 if(!isSideViewGravity() && (moveflags & FLAG_CAN_WATERDROWN))
3441 {
3442 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
3443 {
3444 drownCombo = check_water();
3445 }
3446 }
3447
3448 15718848 runKnockback(); //scripted knockback handling
3449
3450 // clk is incremented here
3451
2/2
✓ Branch 0 taken 14918060 times.
✓ Branch 1 taken 800788 times.
15718848 if(++clk >= frate)
3452 800788 clk=0;
3453
3454 // hit and death handling
3455
2/2
✓ Branch 0 taken 15154871 times.
✓ Branch 1 taken 563977 times.
15718848 if(hclk>0)
3456 563977 --hclk;
3457
3458
2/2
✓ Branch 0 taken 15420037 times.
✓ Branch 1 taken 298811 times.
15718848 if(stunclk>0)
3459 298811 --stunclk;
3460
1/2
✓ Branch 0 taken 15718848 times.
✗ Branch 1 not taken.
15718848 if ( frozenclock > 0 )
3461 --frozenclock;
3462
3463
5/6
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 15711846 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 6947 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
15718848 if(ceiling && z <= 0 && fakez <= 0)
3464 55 ceiling = false;
3465
3466 15718848 try_death();
3467
3468 15718848 scored=false;
3469
3470 15718848 ++c_clk;
3471
3472 //Run its script
3473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15718848 times.
15718848 if (run_script(MODE_NORMAL)==RUNSCRIPT_SELFDELETE)
3474 {
3475 return 0; //Avoid NULLPO if this object deleted itself
3476 }
3477
3478 // returns true when enemy is defeated
3479 15718848 return Dead(index);
3480 15718990 }
3481
3482 16053272 bool enemy::setSolid(bool set)
3483 {
3484
1/2
✓ Branch 0 taken 16053272 times.
✗ Branch 1 not taken.
16053272 bool actual = set && !isSubmerged();
3485 16053272 bool ret = solid_object::setSolid(actual);
3486 16053272 solid = set;
3487 16053272 return ret;
3488 }
3489 void enemy::doContactDamage(int32_t hdir)
3490 {
3491 Hero.hithero(guys.find(this), hdir);
3492 }
3493
3494 90488 void enemy::solid_push(solid_object *obj)
3495 {
3496
1/2
✓ Branch 0 taken 90488 times.
✗ Branch 1 not taken.
90488 if(obj == this) return; //can't push self
3497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90488 times.
90488 if(moveflags&FLAG_NOT_PUSHABLE) return; //not pushable
3498 90488 zfix dx, dy;
3499 90488 int32_t hdir = -1;
3500 90488 solid_push_int(obj,dx,dy,hdir);
3501
3502
4/4
✓ Branch 0 taken 89132 times.
✓ Branch 1 taken 1356 times.
✓ Branch 2 taken 87240 times.
✓ Branch 3 taken 1892 times.
90488 if(!dx && !dy) return;
3503
3504 3248 bool t = obj->getTempNonsolid();
3505 3248 obj->setTempNonsolid(true);
3506
3507 3248 int32_t ydir = dy > 0 ? down : up;
3508 3248 int32_t xdir = dx > 0 ? right : left;
3509
3510 3248 auto special = isflier(id) ? spw_floater : spw_none;
3511
2/2
✓ Branch 0 taken 2905 times.
✓ Branch 1 taken 343 times.
3248 if(!movexy(dx,dy,special,true,true))
3512 {
3513 //Crushed?
3514 343 }
3515
3516 3248 obj->setTempNonsolid(t);
3517 90488 }
3518 90488 bool enemy::is_unpushable() const
3519 {
3520 90488 return isSubmerged();
3521 }
3522 90488 bool enemy::sideview_mode() const
3523 {
3524
3/4
✓ Branch 0 taken 24300 times.
✓ Branch 1 taken 66188 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24300 times.
90488 return isSideViewGravity() && (moveflags&FLAG_OBEYS_GRAV) && !(moveflags&FLAG_NOT_PUSHABLE);
3525 }
3526
3527 2252 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
3528 {
3529 2252 int32_t yg = (special==spw_floater)?8:0;
3530 2252 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3531
3532
8/10
✓ Branch 0 taken 1702 times.
✓ Branch 1 taken 550 times.
✓ Branch 2 taken 494 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 550 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 550 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1704 times.
✓ Branch 9 taken 2254 times.
2252 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
3533 3406 return true;
3534
3535 2254 bool isInDungeon = isdungeon();
3536
3/4
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 2139 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
2254 if(isInDungeon || special==spw_wizzrobe)
3537 {
3538
7/8
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 1707 times.
✓ Branch 2 taken 427 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 433 times.
✓ Branch 5 taken 1279 times.
✓ Branch 6 taken 433 times.
✗ Branch 7 not taken.
2139 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
3539 860 return true;
3540
3541
7/8
✓ Branch 0 taken 426 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 427 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 427 times.
✓ Branch 5 taken 427 times.
✓ Branch 6 taken 427 times.
✗ Branch 7 not taken.
1279 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
3542
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
854 if(special!=spw_door) // walk in door way
3543 return true;
3544 427 }
3545
3546
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 542 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
542 if(!(moveflags & FLAG_CAN_PITWALK) && !(moveflags & FLAG_CAN_PITFALL)) //Don't walk into pits (knockback doesn't call this func)
3547 {
3548 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3549 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3550 return true;
3551 }
3552
3553
1/4
✓ Branch 0 taken 542 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
542 switch(special)
3554 {
3555 case spw_clipbottomright:
3556 if(dy>=128 || dx>=208) return true;
3557 break;
3558 case spw_clipright:
3559 break; //if(x>=208) return true; break;
3560
3561 case spw_wizzrobe: // fall through
3562 case spw_floater: // Special case for fliers and wizzrobes - hack!
3563 {
3564
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 427 times.
542 if(isInDungeon)
3565 {
3566
2/4
✓ Branch 0 taken 427 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 427 times.
427 if(dy < 32-yg || dy >= 144) return true;
3567
2/4
✓ Branch 0 taken 427 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 427 times.
427 if(dx < 32 || dx >= 224) return true;
3568 427 }
3569 542 return false;
3570 }
3571 }
3572
3573 dx&=(special==spw_halfstep)?(~7):(~15);
3574 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
3575
3576 if(special==spw_water)
3577 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
3578
3579 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3580 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
3581 550 }
3582
3583 607 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
3584 {
3585 607 bool kb = false;
3586 607 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3587
3588
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 607 times.
✓ Branch 2 taken 499 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 607 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 607 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 607 times.
607 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
3589 return true;
3590
3591
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 481 times.
607 if(isdungeon())
3592 {
3593
2/4
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 481 times.
481 if((dy<32) || (dy>=144))
3594 return true;
3595
3596
2/4
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 481 times.
481 if((dx<32) || (dx>=224))
3597 return true;
3598 481 }
3599
3600
2/4
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 607 times.
607 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL))) //Don't walk into pits, unless being knocked back
3601 {
3602
2/4
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 607 times.
1214 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3603
2/4
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 607 times.
✗ Branch 3 not taken.
607 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3604 return true;
3605 607 }
3606
3607
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if(get_bit(quest_rules,qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
3608 {
3609
3/4
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 595 times.
✗ Branch 3 not taken.
1202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 595 times.
595 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3611 }
3612 else
3613 {
3614 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
3615 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3616 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
3617 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3618 }
3619 607 }
3620
3621 15992435 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
3622 {
3623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15992435 times.
15992435 if(moveflags & FLAG_USE_NEW_MOVEMENT)
3624 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
3625 15992435 int32_t yg = (special==spw_floater)?8:0;
3626 15992435 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3627
2/2
✓ Branch 0 taken 1502329 times.
✓ Branch 1 taken 14490106 times.
15992435 switch(dir)
3628 {
3629 case l_down:
3630 case r_down:
3631 case down:
3632 case 11: //r_down
3633 case 12: //down
3634 case 13: //l_down
3635 {
3636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1502329 times.
1502329 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
3637 {
3638
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1502329 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1502329 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT && !isflier(id) )
3639 {
3640 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
3641 dy += zc_max(hysz-16,0);
3642 }
3643 1502329 }
3644 1502329 break;
3645 }
3646 }
3647
2/2
✓ Branch 0 taken 1512864 times.
✓ Branch 1 taken 14479571 times.
15992435 switch(dir)
3648 {
3649 case r_up:
3650 case r_down:
3651 case right:
3652 case 9: //r_up
3653 case 10: //right
3654 case 11: //r_down
3655 {
3656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1512864 times.
1512864 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
3657 {
3658
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1512864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1512864 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH && !isflier(id) )
3659 {
3660 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
3661 dx += zc_max(hxsz-16,0);
3662 }
3663 1512864 }
3664 1512864 break;
3665 }
3666 }
3667 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
3668
3669
10/10
✓ Branch 0 taken 11964608 times.
✓ Branch 1 taken 4027827 times.
✓ Branch 2 taken 1106864 times.
✓ Branch 3 taken 2920963 times.
✓ Branch 4 taken 4021024 times.
✓ Branch 5 taken 6803 times.
✓ Branch 6 taken 4015201 times.
✓ Branch 7 taken 5823 times.
✓ Branch 8 taken 11977445 times.
✓ Branch 9 taken 15992646 times.
15992435 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
3670 23954679 return true;
3671
3672 15992646 bool isInDungeon = isdungeon();
3673
4/4
✓ Branch 0 taken 813467 times.
✓ Branch 1 taken 15179179 times.
✓ Branch 2 taken 611 times.
✓ Branch 3 taken 812856 times.
15992646 if(isInDungeon || special==spw_wizzrobe)
3674 {
3675
8/8
✓ Branch 0 taken 3127326 times.
✓ Branch 1 taken 12052464 times.
✓ Branch 2 taken 3020517 times.
✓ Branch 3 taken 106809 times.
✓ Branch 4 taken 3093839 times.
✓ Branch 5 taken 9065434 times.
✓ Branch 6 taken 3093825 times.
✓ Branch 7 taken 14 times.
15179790 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
3676 6114342 return true;
3677
3678
8/8
✓ Branch 0 taken 3054035 times.
✓ Branch 1 taken 6011413 times.
✓ Branch 2 taken 2971251 times.
✓ Branch 3 taken 82784 times.
✓ Branch 4 taken 3027621 times.
✓ Branch 5 taken 3066576 times.
✓ Branch 6 taken 3027618 times.
✓ Branch 7 taken 3 times.
9065448 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
3679
2/2
✓ Branch 0 taken 56336 times.
✓ Branch 1 taken 31 times.
5998869 if(special!=spw_door) // walk in door way
3680 56336 return true;
3681 3066610 }
3682
3683
6/6
✓ Branch 0 taken 1091848 times.
✓ Branch 1 taken 2787618 times.
✓ Branch 2 taken 426951 times.
✓ Branch 3 taken 664897 times.
✓ Branch 4 taken 34241 times.
✓ Branch 5 taken 392710 times.
3879466 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
3684 {
3685
3/4
✓ Branch 0 taken 1057600 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1057600 times.
2115207 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3686
2/4
✓ Branch 0 taken 1057600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1057600 times.
✗ Branch 3 not taken.
1057600 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3687 7 return true;
3688 1057600 }
3689
3690
4/4
✓ Branch 0 taken 3153082 times.
✓ Branch 1 taken 723388 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 2944 times.
3879459 switch(special)
3691 {
3692 case spw_clipbottomright:
3693
2/4
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
45 if(dy>=128 || dx>=208) return true;
3694 45 break;
3695 case spw_clipright:
3696 2944 break; //if(input_x>=208) return true; break;
3697
3698 case spw_wizzrobe: // fall through
3699 case spw_floater: // Special case for fliers and wizzrobes - hack!
3700 {
3701
2/2
✓ Branch 0 taken 534198 times.
✓ Branch 1 taken 2618884 times.
3153082 if(isInDungeon)
3702 {
3703
3/4
✓ Branch 0 taken 2618873 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2618873 times.
2618884 if(dy < 32-yg || dy >= 144) return true;
3704
3/4
✓ Branch 0 taken 2618081 times.
✓ Branch 1 taken 792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2618081 times.
2618873 if(dx < 32 || dx >= 224) return true;
3705 2618081 }
3706 3152279 return false;
3707 }
3708 }
3709
3710 726377 dx&=(special==spw_halfstep)?(~7):(~15);
3711
2/2
✓ Branch 0 taken 152931 times.
✓ Branch 1 taken 573446 times.
726377 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
3712
3713
2/2
✓ Branch 0 taken 84168 times.
✓ Branch 1 taken 642209 times.
726377 if(special==spw_water)
3714
2/2
✓ Branch 0 taken 5232 times.
✓ Branch 1 taken 78936 times.
84168 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
3715
3716
2/2
✓ Branch 0 taken 636979 times.
✓ Branch 1 taken 5230 times.
642209 if(get_bit(quest_rules,qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
3717 {
3718
4/4
✓ Branch 0 taken 479629 times.
✓ Branch 1 taken 157350 times.
✓ Branch 2 taken 475513 times.
✓ Branch 3 taken 4116 times.
1112492 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3719
2/2
✓ Branch 0 taken 2586 times.
✓ Branch 1 taken 472927 times.
475513 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3720 }
3721 else
3722 {
3723
4/4
✓ Branch 0 taken 4290 times.
✓ Branch 1 taken 940 times.
✓ Branch 2 taken 4182 times.
✓ Branch 3 taken 108 times.
9412 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
3724
4/4
✓ Branch 0 taken 4055 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 4042 times.
✓ Branch 3 taken 13 times.
4182 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3725
3/4
✓ Branch 0 taken 3958 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 3958 times.
✗ Branch 3 not taken.
4042 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
3726
1/2
✓ Branch 0 taken 3958 times.
✗ Branch 1 not taken.
3958 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3727 }
3728 4034573 }
3729
3730 424253 bool enemy::isOnSideviewPlatform()
3731 {
3732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 424253 times.
424253 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
3733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 424253 times.
424253 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
3734
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 413947 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
424253 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
3735
2/2
✓ Branch 0 taken 2205 times.
✓ Branch 1 taken 421837 times.
424042 if(check_slope(x, y+1, usewid, usehei)) return true;
3736
2/2
✓ Branch 0 taken 421837 times.
✓ Branch 1 taken 172374 times.
594211 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
3737 {
3738
2/2
✓ Branch 0 taken 172374 times.
✓ Branch 1 taken 249463 times.
421837 if(_walkflag(nx,y+usehei,1)) return true;
3739
3/4
✓ Branch 0 taken 172374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124615 times.
✓ Branch 3 taken 47759 times.
172374 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
3740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47759 times.
47759 if(checkSVLadderPlatform(nx,y+usehei)) return true;
3741 47759 }
3742 172374 return false;
3743 424253 }
3744
3745 // Stops playing the given sound only if there are no enemies left to play it
3746 323568 void enemy::stop_bgsfx(int32_t index)
3747 {
3748
2/2
✓ Branch 0 taken 315094 times.
✓ Branch 1 taken 8474 times.
323568 if(bgsfx<=0)
3749 315094 return;
3750
3751 // Look for other enemies with the same bgsfx
3752
2/2
✓ Branch 0 taken 35975 times.
✓ Branch 1 taken 4854 times.
40829 for(int32_t i=0; i<guys.Count(); i++)
3753 {
3754
4/4
✓ Branch 0 taken 30093 times.
✓ Branch 1 taken 5882 times.
✓ Branch 2 taken 3620 times.
✓ Branch 3 taken 26473 times.
35975 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
3755 3620 return;
3756 32355 }
3757
3758 4854 stop_sfx(bgsfx);
3759 323568 }
3760
3761
3762 // to allow for different sfx on defeating enemy
3763 16454 void enemy::death_sfx()
3764 {
3765
1/2
✓ Branch 0 taken 16454 times.
✗ Branch 1 not taken.
16454 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
3766 16454 }
3767
3768 void enemy::move(zfix dx,zfix dy)
3769 {
3770 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
3771 {
3772 switch(family)
3773 {
3774 case eeFIRE:
3775 case eeOTHER:
3776 return;
3777 default: break;
3778 }
3779 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
3780 }
3781 */
3782 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV) || !enemycanfall(id)))
3783 {
3784 x+=dx;
3785 y+=dy;
3786 }
3787 }
3788
3789 7730342 void enemy::move(zfix s)
3790 {
3791 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
3792 {
3793 switch(family)
3794 {
3795 case eeFIRE:
3796 case eeOTHER:
3797 return;
3798 default: break;
3799 }
3800 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
3801 }*/
3802
9/10
✓ Branch 0 taken 7730315 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 94766 times.
✓ Branch 3 taken 7635549 times.
✓ Branch 4 taken 41896 times.
✓ Branch 5 taken 52870 times.
✓ Branch 6 taken 2027 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 2027 times.
✗ Branch 9 not taken.
7730342 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & FLAG_OBEYS_GRAV)))
3803 {
3804 7728288 sprite::move(s);
3805 7728288 }
3806 7730342 }
3807
3808 17069 void enemy::leave_item()
3809 {
3810 17069 int32_t drop_item = select_dropitem(item_set, x, y);
3811 17069 int32_t thedropset = item_set;
3812
3813 17069 std::vector<int32_t> &ev = FFCore.eventData;
3814 17069 ev.clear();
3815 17069 ev.push_back(getUID());
3816 17069 ev.push_back(drop_item*10000);
3817 17069 ev.push_back(thedropset*10000);
3818
3819 17069 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
3820 17069 drop_item = vbound(ev[1] / 10000,-2,255);
3821 17069 thedropset = ev[2] / 10000;
3822 17069 ev.clear();
3823
1/2
✓ Branch 0 taken 17069 times.
✗ Branch 1 not taken.
17069 if(drop_item == -2)
3824 {
3825 drop_item = select_dropitem(thedropset,x,y);
3826 }
3827
3828
6/6
✓ Branch 0 taken 6904 times.
✓ Branch 1 taken 10165 times.
✓ Branch 2 taken 299 times.
✓ Branch 3 taken 6605 times.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 280 times.
17069 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
3829 {
3830 item* itm;
3831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6885 times.
6885 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
3832 {
3833 itm = (new item(x+hxofs+(hxsz/2)-8,y+hyofs+(hysz/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3834 }
3835 else
3836 {
3837
8/14
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 6602 times.
✓ Branch 2 taken 283 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 283 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 283 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 283 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 283 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 283 times.
✗ Branch 13 not taken.
6885 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3838
4/8
✓ Branch 0 taken 6602 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6602 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6602 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6602 times.
✗ Branch 7 not taken.
6602 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3839 }
3840 6885 itm->from_dropset = thedropset;
3841 6885 items.add(itm);
3842
3843 6885 ev.push_back(getUID());
3844 6885 ev.push_back(itm->getUID());
3845
3846 6885 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
3847 6885 ev.clear();
3848 6885 }
3849 17069 }
3850
3851 // auomatically kill off enemy (for rooms with ringleaders)
3852 289 void enemy::kickbucket()
3853 {
3854
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 25 times.
289 if(!superman)
3855 264 hp=-1000; // don't call death_sfx()
3856 289 }
3857
3858 90488 bool enemy::isSubmerged() const
3859 {
3860 90488 return submerged;
3861 //!TODO SOLIDPUSH more things like teleporting wizzrobes
3862 }
3863
3864 17356 void enemy::FireBreath(bool seekhero)
3865 {
3866
1/2
✓ Branch 0 taken 17356 times.
✗ Branch 1 not taken.
17356 if(wpn==wNone)
3867 return;
3868
3869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17356 times.
17356 if(wpn==ewFireTrail)
3870 {
3871 dmisc1 = e1tEACHTILE;
3872 FireWeapon();
3873 return;
3874 }
3875
3876 17356 float fire_angle=0.0;
3877 17356 int32_t wx=0, wy=0, wdir=dir;
3878
3879
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 15704 times.
17356 if(!seekhero)
3880 {
3881
4/5
✓ Branch 0 taken 3271 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3038 times.
✓ Branch 3 taken 5264 times.
✓ Branch 4 taken 4131 times.
15704 switch(dir)
3882 {
3883 case down:
3884 3038 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
3885 3038 wx=x;
3886 3038 wy=y+8;
3887 3038 break;
3888
3889 case -1:
3890 case up:
3891 3271 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
3892 3271 wx=x;
3893 3271 wy=y-8;
3894 3271 break;
3895
3896 case left:
3897 5264 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
3898 5264 wx=x-8;
3899 5264 wy=y;
3900 5264 break;
3901
3902 case right:
3903 4131 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
3904 4131 wx=x+8;
3905 4131 wy=y;
3906 4131 break;
3907 }
3908
3909
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15704 if(wpn==ewFlame || wpn==ewFlame2)
3910 {
3911
2/4
✓ Branch 0 taken 15704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15704 times.
15704 if(fire_angle==-PI || fire_angle==PI) wdir=left;
3912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==-PI/2) wdir=up;
3913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==PI/2) wdir=down;
3914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==0) wdir=right;
3915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<-PI/2) wdir=l_up;
3916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<0) wdir=r_up;
3917
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14206 times.
15704 else if(fire_angle<(PI/2)) wdir=r_down;
3918
2/2
✓ Branch 0 taken 10090 times.
✓ Branch 1 taken 4116 times.
14206 else if(fire_angle<PI) wdir=l_down;
3919 15704 }
3920 15704 }
3921 else
3922 {
3923 1652 wx = x;
3924 1652 wy = y;
3925 }
3926
3927
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 15704 times.
17356 addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
3928 17356 sfx(wpnsfx(wpn),pan(int32_t(x)));
3929
3930 17356 int32_t i=Ewpns.Count()-1;
3931 17356 weapon *ew = (weapon*)(Ewpns.spr(i));
3932 17356 ew->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
3933
3934
4/4
✓ Branch 0 taken 15704 times.
✓ Branch 1 taken 1652 times.
✓ Branch 2 taken 7830 times.
✓ Branch 3 taken 7874 times.
17356 if(!seekhero && (zc_oldrand()&4))
3935 {
3936 7874 ew->angular=true;
3937 7874 ew->angle=fire_angle;
3938 7874 }
3939
3940
4/4
✓ Branch 0 taken 17299 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 16982 times.
17356 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
3941 {
3942 16982 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
3943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16982 times.
16982 if ( ew->do_animation ) ew->tile+=ew->aframe;
3944 16982 }
3945
3946
2/2
✓ Branch 0 taken 17356 times.
✓ Branch 1 taken 542966 times.
560322 for(int32_t j=Ewpns.Count()-1; j>0; j--)
3947 {
3948 542966 Ewpns.swap(j,j-1);
3949 542966 }
3950 17356 }
3951
3952 21276 void enemy::FireWeapon()
3953 {
3954 /*
3955 * Type:
3956 * 0x01: Boss fireball
3957 * 0x02: Seeks Hero
3958 * 0x04: Fast projectile
3959 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
3960 */
3961
3962
1/2
✓ Branch 0 taken 21276 times.
✗ Branch 1 not taken.
21276 if (wpn < 1) return;
3963
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 21276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
21276 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
3964 return;
3965
3966
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21276 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
3967 dmisc1 = e1tEACHTILE;
3968
3969 21276 int32_t xoff = 0;
3970 21276 int32_t yoff = 0;
3971
1/2
✓ Branch 0 taken 21276 times.
✗ Branch 1 not taken.
21276 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
3972 {
3973 xoff += (hxsz/2)-8;
3974 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
3975 }
3976
1/2
✓ Branch 0 taken 21276 times.
✗ Branch 1 not taken.
21276 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
3977 {
3978 yoff += (hysz/2)-8;
3979 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
3980 }
3981
3982
4/8
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 19865 times.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
21276 switch(dmisc1)
3983 {
3984 case e1t5SHOTS: //BS-Aquamentus
3985 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
3986 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
3987 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
3988 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
3989
3990 [[fallthrough]];
3991 case e1t3SHOTSFAST:
3992 case e1t3SHOTS: //Aquamentus
3993
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
3994 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
3995
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
3996 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
3997
3998 [[fallthrough]];
3999 default:
4000
11/20
✓ Branch 0 taken 20278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20278 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20278 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20278 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20278 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 20278 times.
✓ Branch 12 taken 20278 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 10334 times.
✓ Branch 15 taken 9944 times.
✓ Branch 16 taken 20278 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 20278 times.
✗ Branch 19 not taken.
20278 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
4001 20278 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4002 20278 sfx(wpnsfx(wpn),pan(int32_t(x)));
4003 20278 break;
4004
4005 case e1tSLANT:
4006 {
4007 409 int32_t slant = 0;
4008
4009
10/10
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 197 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 152 times.
✓ Branch 6 taken 60 times.
✓ Branch 7 taken 304 times.
✓ Branch 8 taken 131 times.
✓ Branch 9 taken 173 times.
409 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
4010 236 slant = left;
4011
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 109 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 51 times.
✓ Branch 7 taken 85 times.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 61 times.
173 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
4012 112 slant = right;
4013
4014
9/18
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 319 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 319 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 319 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 319 times.
✓ Branch 14 taken 319 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 319 times.
✗ Branch 17 not taken.
319 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
4015 319 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4016 319 sfx(wpnsfx(wpn),pan(int32_t(x)));
4017 319 break;
4018 }
4019
4020 case e1t8SHOTS: //Fire Wizzrobe
4021 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
4022 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4023 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4024 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
4025 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4026 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4027 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
4028 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4029 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4030 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
4031 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4032 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4033
4034 [[fallthrough]];
4035 case e1t4SHOTS: //Stalfos 3
4036
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
4037 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4038 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4039
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
4040 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4041 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4042
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
4043 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4044 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4045
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
4046 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4047 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4048 589 sfx(wpnsfx(wpn),pan(int32_t(x)));
4049 589 break;
4050
4051 case e1tSUMMON: // Bat Wizzrobe
4052 {
4053 //al_trace("Summon Bats\n");
4054 //zprint2("Summon Bats\n");
4055 if(dmisc4==0) break; // Summon 0
4056
4057 int32_t bc=0;
4058
4059 for(int32_t gc=0; gc<guys.Count(); gc++)
4060 {
4061 if((((enemy*)guys.spr(gc))->id) == dmisc3)
4062 {
4063 ++bc;
4064 }
4065 }
4066
4067 if(bc<=40) // Not too many enemies
4068 {
4069 int32_t kids = guys.Count();
4070 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
4071
4072 for(int32_t i=0; i<bats; i++)
4073 {
4074 //zprint2("summon\n");
4075 //al_trace("summon\n");
4076 if(addchild(x,y,dmisc3,-10, this->script_UID))
4077 {
4078 ((enemy*)guys.spr(kids+i))->count_enemy = false;
4079 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
4080 //zprint2("Summoner Script UID: %d\n",this->script_UID);
4081
4082 }
4083 }
4084
4085 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
4086 }
4087
4088 break;
4089 }
4090
4091 case e1tSUMMONLAYER: // Summoner
4092 {
4093 if(count_layer_enemies()==0)
4094 {
4095 break;
4096 }
4097
4098 int32_t kids = guys.Count();
4099
4100 if(kids<40)
4101 {
4102 int32_t newguys=(zc_oldrand()%3)+1;
4103 bool summoned=false;
4104
4105 for(int32_t i=0; i<newguys; i++)
4106 {
4107 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
4108 int32_t x2=0;
4109 int32_t y2=0;
4110
4111 for(int32_t k=0; k<20; ++k)
4112 {
4113 x2=16*((zc_oldrand()%12)+2);
4114 y2=16*((zc_oldrand()%7)+2);
4115
4116 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
4117 {
4118 //zprint2("summon\n");
4119 //al_trace("summon\n");
4120 if(addchild(x2,y2,get_bit(quest_rules,qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
4121 {
4122 ((enemy*)guys.spr(kids+i))->count_enemy = false;
4123 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
4124 if (get_bit(quest_rules,qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
4125 {
4126 ((enemy*)guys.spr(kids+i))->fakez = 64;
4127 ((enemy*)guys.spr(kids+i))->z = 0;
4128 }
4129 }
4130
4131 summoned=true;
4132 break;
4133 }
4134 }
4135 }
4136
4137 if(summoned)
4138 {
4139 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
4140 }
4141 }
4142
4143 break;
4144 }
4145 }
4146 21186 }
4147
4148
4149 // Hit the shield(s)?
4150 // Apparently, this function is only used for hookshots...
4151 89 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
4152 {
4153
4/6
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 43 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 43 times.
89 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
4154 43 return false;
4155
4156 46 bool ret = false;
4157
4158 // TODO: There must be some bitwise operations that can simplify this...
4159
8/12
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 21 times.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
46 if(wpny > y) ret = ((flags&inv_front && xdir==down) || (flags&inv_back && xdir==up) || (flags&inv_left && xdir==left) || (flags&inv_right && xdir==right));
4160
7/12
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
25 else if(wpny < y) ret = ((flags&inv_front && xdir==up) || (flags&inv_back && xdir==down) || (flags&inv_left && xdir==right) || (flags&inv_right && xdir==left));
4161
4162
9/14
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 9 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 9 times.
✓ Branch 12 taken 9 times.
✗ Branch 13 not taken.
46 if(wpnx < x) ret = ret || ((flags&inv_front && xdir==left) || (flags&inv_back && xdir==right) || (flags&inv_left && xdir==up) || (flags&inv_right && xdir==down));
4163
9/14
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 28 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 28 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 28 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 28 times.
36 else if(wpnx > x) ret = ret || ((flags&inv_front && xdir==right) || (flags&inv_back && xdir==left) || (flags&inv_left && xdir==down) || (flags&inv_right && xdir==up));
4164
4165 46 return ret;
4166 89 }
4167
4168
4169 //! Weapon Editor for 2.6
4170 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
4171
4172
4173 //converts a wqeapon ID to its defence index.
4174 57260 int32_t weaponToDefence(int32_t wid)
4175 {
4176
20/44
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 26558 times.
✓ Branch 3 taken 6326 times.
✓ Branch 4 taken 14566 times.
✓ Branch 5 taken 579 times.
✓ Branch 6 taken 27 times.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 718 times.
✓ Branch 10 taken 5243 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 99 times.
✓ Branch 14 taken 560 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 298 times.
✓ Branch 18 taken 764 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 106 times.
✓ Branch 21 taken 89 times.
✓ Branch 22 taken 5 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 222 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 11 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 12 times.
✓ Branch 34 taken 77 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 952 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
57260 switch(wid)
4177 {
4178 case wNone: return -1;
4179 26558 case wSword: return edefSWORD;
4180 6326 case wBeam: return edefBEAM;
4181 14566 case wBrang: return edefBRANG;
4182 579 case wBomb: return edefBOMB;
4183 27 case wSBomb: return edefSBOMB;
4184 48 case wLitBomb: return edefBOMB;
4185 case wLitSBomb: return edefSBOMB;
4186 718 case wArrow: return edefARROW;
4187 5243 case wFire: return edefFIRE;
4188 case wWhistle:
4189 {
4190 //al_trace("Weapon resolved as a whistle, using edef: %s\n", "edefWhistle");
4191 return edefWhistle;
4192 }
4193 case wBait: return edefBAIT;
4194 99 case wWand: return edefWAND;
4195 560 case wMagic: return edefMAGIC;
4196 case wCatching: return -1;
4197 case wWind: return edefWIND;
4198 298 case wRefMagic: return edefREFMAGIC;
4199 764 case wRefFireball: return edefREFBALL;
4200 case wRefRock: return edefREFROCK;
4201 106 case wHammer: return edefHAMMER;
4202 89 case wHookshot: return edefHOOKSHOT;
4203 5 case wHSHandle: return edefHOOKSHOT;
4204 case wHSChain: return edefHOOKSHOT;
4205 case wSSparkle: return edefSPARKLE;
4206 222 case wFSparkle: return edefSPARKLE;
4207 case wSmack: return -1; // is this the candle object?
4208 case wPhantom: return -1; //engine created visual effects.
4209 case wCByrna: return edefBYRNA;
4210 11 case wRefBeam: return edefREFBEAM;
4211 case wStomp: return edefSTOMP;
4212 case wScript1: return edefSCRIPT01;
4213 case wScript2: return edefSCRIPT02;
4214 12 case wScript3: return edefSCRIPT03;
4215 77 case wScript4: return edefSCRIPT04;
4216 case wScript5: return edefSCRIPT05;
4217 case wScript6: return edefSCRIPT06;
4218 case wScript7: return edefSCRIPT07;
4219 case wScript8: return edefSCRIPT08;
4220 case wScript9: return edefSCRIPT09;
4221 952 case wScript10: return edefSCRIPT10;
4222 case wIce: return edefICE;
4223 case wSound: return edefSONIC;
4224 case wThrown: return edefTHROWN;
4225 //case wPot: return edefPOT;
4226 // case wLitZap: return edefELECTRIC;
4227 // case wZ3Sword: return edefZ3SWORD;
4228 // case wLASWord: return edefLASWORD;
4229 // case wSpinAttk: return edefSPINATTK;
4230 // case wShield: return edefSHIELD;
4231 // case wTrowel: return edefTROWEL;
4232
4233 default: return -1;
4234 }
4235 57260 }
4236
4237 57260 int32_t getDefType(weapon *w)
4238 {
4239 57260 int32_t id = getWeaponID(w);
4240 57260 int32_t edef = weaponToDefence(id);
4241
2/2
✓ Branch 0 taken 57166 times.
✓ Branch 1 taken 94 times.
57260 if(edef == edefHOOKSHOT)
4242 {
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(w->family_class == itype_switchhook)
4244 return edefSwitchHook;
4245 94 }
4246 57260 return edef;
4247 57260 }
4248
4249 99865 int32_t getWeaponID(weapon *w)
4250 {
4251 99865 int32_t usewpn = w->useweapon;
4252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99865 times.
99865 return (usewpn > 0) ? usewpn : w->id;
4253 }
4254
4255 57260 int32_t enemy::resolveEnemyDefence(weapon *w)
4256 {
4257 //sword edef is 9, but we're reading it at 0
4258 //,
4259 57260 int32_t weapondef = 0;
4260 57260 int32_t wdeftype = getDefType(w);
4261 57260 int32_t usedef = w->usedefence;
4262
4263
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 57260 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
57260 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
4264 {
4265 weapondef = usedef*-1;
4266 }
4267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57260 times.
57260 else if(unsigned(wdeftype) < edefLAST255)
4268 {
4269 57260 weapondef = wdeftype;
4270 57260 }
4271 57260 return weapondef;
4272 }
4273
4274 62211 byte get_def_ignrflag(int32_t edef)
4275 {
4276
3/3
✓ Branch 0 taken 52136 times.
✓ Branch 1 taken 1864 times.
✓ Branch 2 taken 8211 times.
62211 switch(edef)
4277 {
4278 case edIGNORE:
4279 case edIGNOREL1:
4280 case edSTUNORIGNORE:
4281 8211 return WPNUNB_IGNR;
4282 case edSTUNORCHINK:
4283 case edCHINK:
4284 case edCHINKL1:
4285 case edCHINKL2:
4286 case edCHINKL4:
4287 case edCHINKL6:
4288 case edCHINKL8:
4289 case edCHINKL10:
4290 case edLEVELCHINK2:
4291 case edLEVELCHINK3:
4292 case edLEVELCHINK4:
4293 case edLEVELCHINK5:
4294 1864 return WPNUNB_BLOCK;
4295 }
4296 52136 return 0;
4297 62211 }
4298
4299 62211 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
4300 {
4301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62211 times.
62211 if(!(unblockable&get_def_ignrflag(edef))) return edef;
4302 switch(edef)
4303 {
4304 case edIGNORE:
4305 case edIGNOREL1:
4306 case edCHINK:
4307 case edCHINKL1:
4308 case edCHINKL2:
4309 case edCHINKL4:
4310 case edCHINKL6:
4311 case edCHINKL8:
4312 case edCHINKL10:
4313 case edLEVELCHINK2:
4314 case edLEVELCHINK3:
4315 case edLEVELCHINK4:
4316 case edLEVELCHINK5:
4317 return edNORMAL;
4318 case edSTUNORIGNORE:
4319 case edSTUNORCHINK:
4320 return edSTUNONLY;
4321 }
4322 return edef;
4323 62211 }
4324
4325 // Do we do damage?
4326 // 0: takehit returns 0
4327 // 1: takehit returns 1
4328 // -1: do damage
4329 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
4330 56308 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
4331 {
4332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56308 times.
56308 if(switch_hooked) return 0;
4333 56308 int32_t tempx = x;
4334 56308 int32_t tempy = y;
4335 56308 int32_t the_defence = 0;
4336
1/2
✓ Branch 0 taken 56308 times.
✗ Branch 1 not taken.
56308 if ( edef < 0 ) //we are using a specific base default defence for a weapon
4337 {
4338 the_defence = edef*-1; //A specific defence type.
4339 }
4340 56308 else the_defence = defense[edef];
4341
4342 56308 the_defence = conv_edef_unblockable(the_defence, unblockable);
4343
4344
3/4
✓ Branch 0 taken 3942 times.
✓ Branch 1 taken 52366 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3942 times.
56308 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
4345 {
4346
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 3941 times.
✓ Branch 2 taken 1 times.
3942 switch(the_defence)
4347 {
4348 case edIGNORE:
4349 1 return 0;
4350 case edIGNOREL1:
4351 case edSTUNORIGNORE:
4352 if(*power <= 0)
4353 return 0;
4354 }
4355 3941 sfx(WAV_CHINK,pan(int32_t(x)));
4356 3941 return 1;
4357 }
4358
4359 52366 int32_t new_id = id;
4360 52366 int32_t effect_type = dmisc15;
4361 52366 int32_t delay_timer = 90;
4362 52366 enemy *gleeok = NULL;
4363 52366 enemy *ptra = NULL;
4364 52366 int32_t c = 0;
4365
4366
15/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1242 times.
✓ Branch 6 taken 460 times.
✓ Branch 7 taken 21 times.
✓ Branch 8 taken 80 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 175 times.
✓ Branch 13 taken 6968 times.
✓ Branch 14 taken 135 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1386 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 79 times.
✓ Branch 26 taken 58 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 41493 times.
52366 switch(the_defence)
4367 {
4368 case edREPLACE:
4369 {
4370 sclk = 0;
4371 if ( dmisc16 > 0 ) new_id = dmisc16;
4372 else new_id = id+1;
4373 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
4374 if ( dmisc17 > 0 ) delay_timer = dmisc17;
4375 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
4376
4377 //Z_scripterrlog("new id is %d\n", new_id);
4378 switch(guysbuf[new_id&0xFFF].family)
4379 {
4380 //Fixme: possible enemy memory leak. (minor)
4381 case eeWALK:
4382 {
4383 enemy *e = new eStalfos(x,y,new_id,clk);
4384 guys.add(e);
4385 }
4386 break;
4387
4388 case eeLEV:
4389 {
4390 enemy *e = new eLeever(x,y,new_id,clk);
4391 guys.add(e);
4392 }
4393 break;
4394
4395 case eeTEK:
4396 {
4397 enemy *e = new eTektite(x,y,new_id,clk);
4398 guys.add(e);
4399 }
4400 break;
4401
4402 case eePEAHAT:
4403 {
4404 enemy *e = new ePeahat(x,y,new_id,clk);
4405 guys.add(e);
4406 }
4407 break;
4408
4409 case eeZORA:
4410 {
4411 enemy *e = new eZora(x,y,new_id,clk);
4412 guys.add(e);
4413 }
4414 break;
4415
4416 case eeGHINI:
4417 {
4418 enemy *e = new eGhini(x,y,new_id,clk);
4419 guys.add(e);
4420 }
4421 break;
4422
4423 case eeKEESE:
4424 {
4425 enemy *e = new eKeese(x,y,new_id,clk);
4426 guys.add(e);
4427 }
4428 break;
4429
4430 case eeWIZZ:
4431 {
4432 enemy *e = new eWizzrobe(x,y,new_id,clk);
4433 guys.add(e);
4434 }
4435 break;
4436
4437 case eePROJECTILE:
4438 {
4439 enemy *e = new eProjectile(x,y,new_id,clk);
4440 guys.add(e);
4441 }
4442 break;
4443
4444 case eeWALLM:
4445 {
4446 enemy *e = new eWallM(x,y,new_id,clk);
4447 guys.add(e);
4448 }
4449 break;
4450
4451 case eeAQUA:
4452 {
4453 enemy *e = new eAquamentus(x,y,new_id,clk);
4454 guys.add(e);
4455 e->x = x;
4456 e->y = y;
4457 }
4458 break;
4459
4460 case eeMOLD:
4461 {
4462 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1)));
4463 guys.add(e);
4464 e->x = x;
4465 e->y = y;
4466 }
4467 break;
4468
4469 case eeMANHAN:
4470 {
4471 enemy *e = new eManhandla(x,y,new_id,clk);
4472 guys.add(e);
4473 e->x = x;
4474 e->y = y;
4475 }
4476 break;
4477
4478 case eeGLEEOK:
4479 {
4480 *power = 0;
4481 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].misc1);
4482 guys.add(gleeok);
4483 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
4484 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
4485 new_id &= 0xFFF;
4486 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
4487 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
4488 for(int32_t i=0; i<head_cnt; i++)
4489 {
4490 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
4491 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
4492 {
4493 al_trace("Gleeok head %d could not be created!\n",i+1);
4494
4495 for(int32_t j=0; j<i+1; j++)
4496 {
4497 guys.del(guys.Count()-1);
4498 }
4499
4500 break;
4501 }
4502 else
4503 {
4504 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
4505 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
4506 }
4507
4508 c-=guysbuf[new_id].misc4;
4509 //gleeok->x = x;
4510 //gleeok->y = y;
4511 //gleeok = e;
4512 }
4513 return 1;
4514 }
4515
4516 case eeGHOMA:
4517 {
4518 enemy *e = new eGohma(x,y,new_id,clk);
4519 guys.add(e);
4520 e->x = x;
4521 e->y = y;
4522 }
4523 break;
4524
4525 case eeLANM:
4526 {
4527 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)));
4528 guys.add(e);
4529 e->x = x;
4530 e->y = y;
4531 }
4532 break;
4533
4534 case eeGANON:
4535 {
4536 enemy *e = new eGanon(x,y,new_id,clk);
4537 guys.add(e);
4538 e->x = x;
4539 e->y = y;
4540 }
4541 break;
4542
4543 case eeFAIRY:
4544 {
4545 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
4546 guys.add(e);
4547 e->x = x;
4548 e->y = y;
4549 }
4550 break;
4551
4552 case eeFIRE:
4553 {
4554 enemy *e = new eFire(x,y,new_id,clk);
4555 guys.add(e);
4556 e->x = x;
4557 e->y = y;
4558 }
4559 break;
4560
4561 case eeOTHER:
4562 {
4563 enemy *e = new eOther(x,y,new_id,clk);
4564 guys.add(e);
4565 e->x = x;
4566 e->y = y;
4567 }
4568 break;
4569
4570 case eeSPINTILE:
4571 {
4572 enemy *e = new eSpinTile(x,y,new_id,clk);
4573 guys.add(e);
4574 e->x = x;
4575 e->y = y;
4576 }
4577 break;
4578
4579 // and these enemies use the misc10/misc2 value
4580 case eeROCK:
4581 {
4582 switch(guysbuf[new_id&0xFFF].misc10)
4583 {
4584 case 1:
4585 {
4586 enemy *e = new eBoulder(x,y,new_id,clk);
4587 guys.add(e);
4588 e->x = x;
4589 e->y = y;
4590 }
4591 break;
4592
4593 case 0:
4594 default:
4595 {
4596 enemy *e = new eRock(x,y,new_id,clk);
4597 guys.add(e);
4598 e->x = x;
4599 e->y = y;
4600 }
4601 break;
4602 }
4603
4604 break;
4605 }
4606
4607 case eeTRAP:
4608 {
4609 switch(guysbuf[new_id&0xFFF].misc2)
4610 {
4611 case 1:
4612 {
4613 enemy *e = new eTrap2(x,y,new_id,clk);
4614 guys.add(e);
4615 e->x = x;
4616 e->y = y;
4617 }
4618 break;
4619
4620 case 0:
4621 default:
4622 {
4623 enemy *e = new eTrap(x,y,new_id,clk);
4624 guys.add(e);
4625 e->x = x;
4626 e->y = y;
4627 }
4628 break;
4629 }
4630
4631 break;
4632 }
4633
4634 case eeDONGO:
4635 {
4636 switch(guysbuf[new_id&0xFFF].misc10)
4637 {
4638 case 1:
4639 {
4640 enemy *e = new eDodongo2(x,y,new_id,clk);
4641 guys.add(e);
4642 e->x = x;
4643 e->y = y;
4644 }
4645 break;
4646
4647 case 0:
4648 default:
4649 {
4650 enemy *e = new eDodongo(x,y,new_id,clk);
4651 guys.add(e);
4652 e->x = x;
4653 e->y = y;
4654 }
4655 break;
4656 }
4657
4658 break;
4659 }
4660
4661 case eeDIG:
4662 {
4663 switch(guysbuf[new_id&0xFFF].misc10)
4664 {
4665 case 1:
4666 {
4667 enemy *e = new eLilDig(x,y,new_id,clk);
4668 guys.add(e);
4669 e->x = x;
4670 e->y = y;
4671 }
4672 break;
4673
4674 case 0:
4675 default:
4676 {
4677 enemy *e = new eBigDig(x,y,new_id,clk);
4678 guys.add(e);
4679 e->x = x;
4680 e->y = y;
4681 }
4682 break;
4683 }
4684
4685 break;
4686 }
4687
4688 case eePATRA:
4689 {
4690 switch(guysbuf[new_id&0xFFF].misc10)
4691 {
4692 case 1:
4693 {
4694 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
4695 {
4696 enemy *e = new ePatraBS(x,y,new_id,clk);
4697 guys.add(e);
4698 e->x = x;
4699 e->y = y;
4700 break;
4701 }
4702 }
4703 [[fallthrough]];
4704 case 0:
4705 default:
4706 {
4707 enemy *e = new ePatra(x,y,new_id,clk);
4708 guys.add(e);
4709 e->x = x;
4710 e->y = y;
4711 }
4712 break;
4713 }
4714
4715 break;
4716 }
4717
4718 case eeGUY:
4719 {
4720 switch(guysbuf[new_id&0xFFF].misc10)
4721 {
4722 case 1:
4723 {
4724 enemy *e = new eTrigger(x,y,new_id,clk);
4725 guys.add(e);
4726 }
4727 break;
4728
4729 case 0:
4730 default:
4731 {
4732 enemy *e = new eNPC(x,y,new_id,clk);
4733 guys.add(e);
4734 }
4735 break;
4736 }
4737
4738 break;
4739 }
4740
4741 case eeSCRIPT01:
4742 case eeSCRIPT02:
4743 case eeSCRIPT03:
4744 case eeSCRIPT04:
4745 case eeSCRIPT05:
4746 case eeSCRIPT06:
4747 case eeSCRIPT07:
4748 case eeSCRIPT08:
4749 case eeSCRIPT09:
4750 case eeSCRIPT10:
4751 case eeSCRIPT11:
4752 case eeSCRIPT12:
4753 case eeSCRIPT13:
4754 case eeSCRIPT14:
4755 case eeSCRIPT15:
4756 case eeSCRIPT16:
4757 case eeSCRIPT17:
4758 case eeSCRIPT18:
4759 case eeSCRIPT19:
4760 case eeSCRIPT20:
4761 {
4762 enemy *e = new eScript(x,y,new_id,clk);
4763 guys.add(e);
4764 e->x = x;
4765 e->y = y;
4766 break;
4767 }
4768
4769
4770 case eeFFRIENDLY01:
4771 case eeFFRIENDLY02:
4772 case eeFFRIENDLY03:
4773 case eeFFRIENDLY04:
4774 case eeFFRIENDLY05:
4775 case eeFFRIENDLY06:
4776 case eeFFRIENDLY07:
4777 case eeFFRIENDLY08:
4778 case eeFFRIENDLY09:
4779 case eeFFRIENDLY10:
4780 {
4781 enemy *e = new eFriendly(x,y,new_id,clk);
4782 guys.add(e);
4783 e->x = x;
4784 e->y = y;
4785 break;
4786 }
4787
4788
4789 default: break;
4790 }
4791
4792 // add segments of segmented enemies
4793 int32_t c=0;
4794
4795 switch(guysbuf[new_id&0xFFF].family)
4796 {
4797 case eeMOLD:
4798 {
4799 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
4800 new_id &= 0xFFF;
4801
4802 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].misc1)); i++)
4803 {
4804 //christ this is messy -DD
4805 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
4806
4807 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
4808 {
4809 al_trace("Moldorm segment %d could not be created!\n",i+1);
4810
4811 for(int32_t j=0; j<i+1; j++)
4812 guys.del(guys.Count()-1);
4813
4814 return 0;
4815 }
4816
4817 if(i>0)
4818 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
4819
4820
4821 }
4822
4823 break;
4824 }
4825
4826 case eeLANM:
4827 {
4828 new_id &= 0xFFF;
4829 int32_t shft = guysbuf[new_id].misc2;
4830 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
4831 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
4832
4833 if(!guys.add(e))
4834 {
4835 al_trace("Lanmola segment 1 could not be created!\n");
4836 guys.del(guys.Count()-1);
4837 return 0;
4838 }
4839 e->x = x;
4840 e->y = y;
4841
4842
4843
4844 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)); i++)
4845 {
4846 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
4847 if(!guys.add(e2))
4848 {
4849 al_trace("Lanmola segment %d could not be created!\n",i+1);
4850
4851 for(int32_t j=0; j<i+1; j++)
4852 guys.del(guys.Count()-1);
4853
4854 return 0;
4855 }
4856 e2->x = x;
4857 e2->y = y;
4858
4859 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
4860
4861 }
4862 }
4863 break;
4864
4865 case eeMANHAN:
4866 new_id &= 0xFFF;
4867
4868 for(int32_t i=0; i<((!(guysbuf[new_id].misc2))?4:8); i++)
4869 {
4870 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
4871 {
4872 al_trace("Manhandla head %d could not be created!\n",i+1);
4873
4874 for(int32_t j=0; j<i+1; j++)
4875 {
4876 guys.del(guys.Count()-1);
4877 }
4878
4879 return 0;
4880 }
4881
4882
4883 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].misc1;
4884 }
4885
4886 break;
4887
4888 case eeGLEEOK:
4889 {
4890 /*
4891 new_id &= 0xFFF;
4892 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
4893 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
4894 for(int32_t i=0; i<head_cnt; i++)
4895 {
4896 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
4897 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
4898 {
4899 al_trace("Gleeok head %d could not be created!\n",i+1);
4900
4901 for(int32_t j=0; j<i+1; j++)
4902 {
4903 guys.del(guys.Count()-1);
4904 }
4905
4906 break;
4907 }
4908
4909 c-=guysbuf[new_id].misc4;
4910 */
4911
4912 // }
4913 }
4914 break;
4915
4916
4917 case eePATRA:
4918 {
4919 new_id &= 0xFFF;
4920 int32_t outeyes = 0;
4921 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
4922
4923 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc1); i++)
4924 {
4925 if(!((guysbuf[new_id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
4926 {
4927 al_trace("Patra outer eye %d could not be created!\n",i+1);
4928
4929 for(int32_t j=0; j<i+1; j++)
4930 guys.del(guys.Count()-1);
4931
4932 return 0;
4933 }
4934 else
4935 outeyes++;
4936
4937
4938 }
4939
4940 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc2); i++)
4941 {
4942 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
4943 {
4944 al_trace("Patra inner eye %d could not be created!\n",i+1);
4945
4946 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
4947 guys.del(guys.Count()-1);
4948
4949 return 0;
4950 }
4951
4952
4953 }
4954 delete ptra;
4955 break;
4956 }
4957 }
4958
4959
4960
4961 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
4962 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
4963 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
4964 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
4965 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
4966 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
4967 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
4968 //((enemy*)guys.spr(guys.Count()-1))->mainguy = this->mainguy; //This might mean that it is a core.
4969 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
4970 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
4971 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
4972 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
4973 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
4974 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
4975
4976
4977 item_set = 0; //Do not make a drop.
4978
4979 switch(effect_type)
4980 {
4981 case -7:
4982 {
4983 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
4984 Lwpns.add(w);
4985 break;
4986 }
4987 case -6:
4988 {
4989 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
4990 Lwpns.add(w);
4991 break;
4992 }
4993 case -5:
4994 {
4995 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
4996 Lwpns.add(w);
4997 break;
4998 }
4999 case -4:
5000 {
5001 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
5002 Lwpns.add(w);
5003 break;
5004 }
5005 case -3: explode(1); break;
5006 case -2: explode(2); break;
5007 case -1: explode(0); break;
5008 case 0: break;
5009
5010 default:
5011 {
5012 //Dummy weapon function
5013 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
5014 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
5015 Lwpns.add(w);
5016 break;
5017 }
5018 }
5019
5020
5021 yofs = -32768;
5022 switch(guysbuf[new_id&0xFFF].family)
5023 {
5024 case eeGLEEOK:
5025 {
5026 Z_scripterrlog("Replacing a gleeok.\n");
5027 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
5028 hp = -999;
5029 tempenemy->hp = -999;
5030 break;
5031
5032 }
5033 default:
5034 hp = -1000; break;
5035 }
5036 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
5037 return 1;
5038
5039 }
5040 case edSPLIT:
5041 {
5042 //int32_t ex = x; int32_t ey = y;
5043 //al_trace("edSplit dmisc3: %d\n", dmisc3);
5044 //al_trace("edSplit dmisc4: %d\n", dmisc4);
5045 /*
5046 if ( txsx > 1 )
5047 {
5048 ex += ( txsz-1 ) * 8; //from its middle
5049 }
5050 if ( tysx > 1 )
5051 {
5052 ey += ( tysz-1 ) * 8; //from its middle
5053 }
5054 */
5055 for ( int32_t q = 0; q < dmisc4; q++ )
5056 {
5057
5058 //addenemy((x+(txsz*16)/2),(y+(tysz*16)/2),dmisc3+0x1000,-15);
5059 addenemy(
5060 //ex,ey,
5061 x,y,
5062 dmisc3+0x1000,-15);
5063 //addenemy(ex,ey,dmisc3,0);
5064
5065 }
5066 item_set = 0; //Do not make a drop.
5067 hp = -1000;
5068 return -1;
5069
5070 }
5071 case edSUMMON:
5072 {
5073
5074
5075 //al_trace("edSplit dmisc3: %d\n", dmisc3);
5076 //al_trace("edSplit dmisc4: %d\n", dmisc4);
5077 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
5078 for ( int32_t q = 0; q < summon_count; q++ )
5079 {
5080 int32_t x2=16*((zc_oldrand()%12)+2);
5081 int32_t y2=16*((zc_oldrand()%7)+2);
5082 addenemy(
5083 //(x+(txsz*16)/2),(y+(tysz*16)/2)
5084 x2,y2,
5085 dmisc3+0x1000,-15);
5086 //addenemy(ex,ey,dmisc3,0);
5087
5088 }
5089 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
5090 return -1;
5091
5092 }
5093
5094 case edEXPLODESMALL:
5095 {
5096 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
5097 Ewpns.add(ew);
5098 item_set = 0; //Should we make a drop?
5099 hp = -1000;
5100 return -1;
5101 }
5102
5103
5104 case edEXPLODEHARMLESS:
5105 {
5106 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
5107 Ewpns.add(ew);
5108 ew->hyofs = -32768;
5109 item_set = 0; //Should we make a drop?
5110 hp = -1000;
5111 return -1;
5112 }
5113
5114
5115 case edEXPLODELARGE:
5116 {
5117 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
5118 Ewpns.add(ew);
5119
5120 hp = -1000;
5121 return -1;
5122 }
5123
5124
5125 case edTRIGGERSECRETS:
5126 {
5127 hidden_entrance(0, true, false, -4);
5128 return -1;
5129 }
5130
5131 case edSTUNORCHINK:
5132
3/4
✓ Branch 0 taken 650 times.
✓ Branch 1 taken 736 times.
✓ Branch 2 taken 650 times.
✗ Branch 3 not taken.
2290 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5133 {
5134 sfx(WAV_CHINK,pan(int32_t(x)));
5135 return 1;
5136 }
5137
2/2
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 904 times.
1386 else if(*power <= 0)
5138 {
5139 //al_trace("defendNew() is at: %s\n", "returning edSTUNORCHINK");
5140 482 sfx(WAV_CHINK,pan(int32_t(x)));
5141 482 return 1;
5142 }
5143 [[fallthrough]];
5144
5145 case edSTUNORIGNORE:
5146
3/4
✓ Branch 0 taken 1128 times.
✓ Branch 1 taken 1018 times.
✓ Branch 2 taken 1128 times.
✗ Branch 3 not taken.
3639 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5147 {
5148 sfx(WAV_CHINK,pan(int32_t(x)));
5149 return 1;
5150 }
5151
2/2
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 1493 times.
2146 else if(*power <= 0)
5152 653 return 0;
5153 [[fallthrough]];
5154
5155 case edSTUNONLY:
5156
7/10
✓ Branch 0 taken 1953 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1953 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1953 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1936 times.
✓ Branch 7 taken 17 times.
✓ Branch 8 taken 1946 times.
✓ Branch 9 taken 7 times.
1953 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
5157 {
5158 //al_trace("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
5159 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
5160 7 return 1;
5161 }
5162
3/4
✓ Branch 0 taken 1438 times.
✓ Branch 1 taken 508 times.
✓ Branch 2 taken 1438 times.
✗ Branch 3 not taken.
1946 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5163 {
5164 sfx(WAV_CHINK,pan(int32_t(x)));
5165 return 1;
5166 }
5167 else
5168 {
5169 1946 stunclk=160;
5170 1946 sfx(WAV_EHIT,pan(int32_t(x)));
5171
5172 1946 return 1;
5173 }
5174
5175 case edCHINKL1:
5176 if(*power >= 1*game->get_hero_dmgmult()) break;
5177 [[fallthrough]];
5178 case edCHINKL2:
5179
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(*power >= 2*game->get_hero_dmgmult()) break;
5180 [[fallthrough]];
5181 case edCHINKL4:
5182
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 19 times.
80 if(*power >= 4*game->get_hero_dmgmult()) break;
5183 [[fallthrough]];
5184 case edCHINKL6:
5185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 6*game->get_hero_dmgmult()) break;
5186 [[fallthrough]];
5187 case edCHINKL8:
5188
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 20 times.
35 if(*power >= 8*game->get_hero_dmgmult()) break;
5189 [[fallthrough]];
5190 case edCHINKL10:
5191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 10*game->get_hero_dmgmult()) break;
5192 [[fallthrough]];
5193 case edCHINK:
5194 //al_trace("defendNew() is at: %s\n", "returning edCHINK");
5195 195 sfx(WAV_CHINK,pan(int32_t(x)));
5196 195 return 1;
5197
5198 case edIGNOREL1:
5199 if(*power > 0) break;
5200 [[fallthrough]];
5201
5202 case edIGNORE:
5203 6968 return 0;
5204
5205 case ed1HKO:
5206 182 *power = hp;
5207 182 return -2;
5208
5209 case ed2x:
5210 {
5211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 *power = zc_max(1,*power*2);
5212 //int32_t pow = *power;
5213 //*power = vbound((pow*2),0,214747);
5214 71 return -1;
5215 }
5216 case ed3x:
5217 {
5218 *power = zc_max(1,*power*3);
5219 //int32_t pow = *power;
5220 //*power = vbound((pow*3),0,214747);
5221 return -1;
5222 }
5223
5224 case ed4x:
5225 {
5226 *power = zc_max(1,*power*4);
5227 //int32_t pow = *power;
5228 //*power = vbound((pow*4),0,214747);
5229 return -1;
5230 }
5231
5232
5233 case edHEAL:
5234 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
5235 //int32_t pow = *power;
5236 //*power = vbound((pow*-1),0,214747);
5237 //break;
5238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 *power = zc_min(0,*power*-1);
5239 79 return -1;
5240 }
5241 /*
5242 case edLEVELDAMAGE:
5243 {
5244 int32_t pow = *power;
5245 int32_t lvl = *level;
5246 *power = vbound((pow*lvl),0,214747);
5247 break;
5248 }
5249 case edLEVELREDUCTION:
5250 {
5251 int32_t pow = *power;
5252 int32_t lvl = *level;
5253 *power = vbound((pow/lvl),0,214747);
5254 break;
5255 }
5256 */
5257
5258 case edQUARTDAMAGE:
5259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 *power = zc_max(1,*power/2);
5260
5261 [[fallthrough]];
5262 case edHALFDAMAGE:
5263
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 192 times.
193 *power = zc_max(1,*power/2);
5264 193 break;
5265
5266 case edSWITCH:
5267 {
5268 if(Hero.switchhookclk) return 0; //Already switching!
5269 switch(family)
5270 {
5271 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
5272 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
5273 return 0;
5274 }
5275 hooked_combopos = -1;
5276 hooked_layerbits = 0;
5277 switching_object = this;
5278 switch_hooked = true;
5279 Hero.doSwitchHook(game->get_switchhookstyle());
5280 if(QMisc.miscsfx[sfxSWITCHED])
5281 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
5282 return 1;
5283 }
5284
5285 case 0:
5286 {
5287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41493 times.
41493 if(edef == edefSwitchHook)
5288 return -1;
5289
6/6
✓ Branch 0 taken 10380 times.
✓ Branch 1 taken 31113 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 10351 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 13 times.
41493 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK) && *power == 0)
5290 {
5291 13 sfx(WAV_CHINK,pan(int32_t(x)));
5292 13 return 1;
5293 }
5294
5295 }
5296 41480 }
5297
5298 41770 return -1;
5299 56308 }
5300
5301 56308 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
5302 {
5303 56308 std::vector<int32_t> &ev = FFCore.eventData;
5304 56308 ev.clear();
5305 56308 ev.push_back(*power*10000);
5306 56308 ev.push_back(edef*10000);
5307 56308 ev.push_back(unblockable*10000);
5308 56308 ev.push_back(wpnId*10000);
5309 56308 ev.push_back(0);
5310 56308 ev.push_back(getUID());
5311
1/2
✓ Branch 0 taken 56308 times.
✗ Branch 1 not taken.
56308 ev.push_back(w?w->getUID():0);
5312
5313 56308 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
5314 56308 *power = ev[0]/10000;
5315 56308 edef = ev[1]/10000;
5316 56308 unblockable = byte(ev[2]/10000);
5317 56308 wpnId = ev[3] / 10000;
5318 56308 bool nullify = ev[4]!=0;
5319 56308 ev.clear();
5320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56308 times.
56308 if(nullify) return 0;
5321
5322 56308 int32_t ret = defendNew(wpnId, power, edef, unblockable);
5323
2/2
✓ Branch 0 taken 15028 times.
✓ Branch 1 taken 41280 times.
56308 if(ret != -1) return ret;
5324 41280 ev.push_back(*power*10000);
5325 41280 ev.push_back(edef*10000);
5326 41280 ev.push_back(unblockable*10000);
5327 41280 ev.push_back(wpnId*10000);
5328 41280 ev.push_back(0);
5329 41280 ev.push_back(getUID());
5330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41280 times.
41280 ev.push_back(w?w->getUID():0);
5331
5332 41280 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
5333 41280 *power = ev[0]/10000;
5334 41280 nullify = ev[4]!=0;
5335 41280 ev.clear();
5336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41280 times.
41280 if(nullify) return 0;
5337 41280 return -1;
5338 56308 }
5339
5340 42605 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w)
5341 {
5342 42605 int32_t wid = getWeaponID(w);
5343
5344 42605 int32_t edef = resolveEnemyDefence(w);
5345
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 41345 times.
42605 if(QHeader.zelda_version > 0x250)
5346 1260 return defendNewInt(wid, power, edef, w->unblockable, w);
5347
2/3
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 40393 times.
✗ Branch 2 not taken.
41345 switch(wid)
5348 {
5349 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
5350 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
5351 952 return defend(wpnId, power, edefSCRIPT);
5352
5353 case wWhistle:
5354 return -1;
5355
5356 default:
5357 40393 return defendNewInt(wid, power, edef, w->unblockable, w);
5358 }
5359 42605 }
5360
5361
5362 // Check defenses without actually acting on them.
5363 6129 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
5364 {
5365
4/10
✓ Branch 0 taken 4176 times.
✓ Branch 1 taken 1723 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6129 switch(defense[edef])
5366 {
5367 case edSTUNONLY:
5368 8 return false;
5369 case edSTUNORCHINK:
5370 case edCHINK:
5371 4176 return unblockable&WPNUNB_BLOCK;
5372 case edSTUNORIGNORE:
5373 case edIGNORE:
5374 1723 return unblockable&WPNUNB_IGNR;
5375
5376 case edIGNOREL1:
5377 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
5378 case edCHINKL1:
5379 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
5380
5381 case edCHINKL2:
5382 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
5383
5384 case edCHINKL4:
5385 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
5386
5387 case edCHINKL6:
5388 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
5389
5390 case edCHINKL8:
5391 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
5392 }
5393
5394 222 return true;
5395 6129 }
5396
5397 // Do we do damage?
5398 // 0: takehit returns 0
5399 // 1: takehit returns 1
5400 // -1: do damage
5401 952 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
5402 {
5403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 952 times.
952 if(shieldCanBlock)
5404 {
5405 switch(defense[edef])
5406 {
5407 case edIGNORE:
5408 return 0;
5409 case edIGNOREL1:
5410 case edSTUNORIGNORE:
5411 if(*power <= 0)
5412 return 0;
5413 }
5414
5415 sfx(WAV_CHINK,pan(int32_t(x)));
5416 return 1;
5417 }
5418
5419
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 759 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
952 switch(defense[edef])
5420 {
5421 case edSTUNORCHINK:
5422 if(*power <= 0)
5423 {
5424 sfx(WAV_CHINK,pan(int32_t(x)));
5425 return 1;
5426 }
5427
5428 [[fallthrough]];
5429 case edSTUNORIGNORE:
5430 if(*power <= 0)
5431 return 0;
5432
5433 [[fallthrough]];
5434 case edSTUNONLY:
5435 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
5436 return 1;
5437
5438 stunclk=160;
5439 sfx(WAV_EHIT,pan(int32_t(x)));
5440 return 1;
5441
5442 case edFREEZE:
5443 frozenclock=-1;
5444 //sfx(WAV_FREEZE,pan(int32_t(x)));
5445 return 1;
5446
5447 case edCHINKL1:
5448 if(*power >= 1*game->get_hero_dmgmult()) break;
5449 [[fallthrough]];
5450 case edCHINKL2:
5451 if(*power >= 2*game->get_hero_dmgmult()) break;
5452 [[fallthrough]];
5453 case edCHINKL4:
5454 if(*power >= 4*game->get_hero_dmgmult()) break;
5455 [[fallthrough]];
5456 case edCHINKL6:
5457 if(*power >= 6*game->get_hero_dmgmult()) break;
5458 [[fallthrough]];
5459 case edCHINKL8:
5460 if(*power >= 8*game->get_hero_dmgmult()) break;
5461 [[fallthrough]];
5462 case edCHINKL10:
5463 if(*power >= 10*game->get_hero_dmgmult()) break;
5464 [[fallthrough]];
5465 case edCHINK:
5466 sfx(WAV_CHINK,pan(int32_t(x)));
5467 return 1;
5468 case edTRIGGERSECRETS:
5469 hidden_entrance(0, true, false, -4);
5470 break;
5471
5472 case edIGNOREL1:
5473 if(*power > 0) break;
5474 [[fallthrough]];
5475 case edIGNORE:
5476 759 return 0;
5477
5478 case ed1HKO:
5479 *power = hp;
5480 return -2;
5481
5482 case ed2x:
5483 {
5484 *power = zc_max(1,*power*2);
5485 //int32_t pow = *power;
5486 //*power = vbound((pow*2),0,214747);
5487 return -1;
5488 }
5489 case ed3x:
5490 {
5491 *power = zc_max(1,*power*3);
5492 //int32_t pow = *power;
5493 //*power = vbound((pow*3),0,214747);
5494 return -1;
5495 }
5496
5497 case ed4x:
5498 {
5499 *power = zc_max(1,*power*4);
5500 //int32_t pow = *power;
5501 //*power = vbound((pow*4),0,214747);
5502 return -1;
5503 }
5504
5505
5506 case edHEAL:
5507 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
5508 //int32_t pow = *power;
5509 //*power = vbound((pow*-1),0,214747);
5510 //break;
5511 *power = zc_min(0,*power*-1);
5512 return -1;
5513 }
5514 /*
5515 case edLEVELDAMAGE:
5516 {
5517 int32_t pow = *power;
5518 int32_t lvl = *level;
5519 *power = vbound((pow*lvl),0,214747);
5520 break;
5521 }
5522 case edLEVELREDUCTION:
5523 {
5524 int32_t pow = *power;
5525 int32_t lvl = *level;
5526 *power = vbound((pow/lvl),0,214747);
5527 break;
5528 }
5529 */
5530
5531
5532 case edQUARTDAMAGE:
5533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
5534
5535 [[fallthrough]];
5536 case edHALFDAMAGE:
5537
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 *power = zc_max(1,*power/2);
5538 7 break;
5539 }
5540
5541 193 return -1;
5542 952 }
5543
5544 // Defend against a particular item class.
5545 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
5546 {
5547 int32_t def=-1;
5548
5549 switch(wpnId)
5550 {
5551 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
5552 case wBrang:
5553 def = defend(wpnId, power, edefBRANG);
5554 break;
5555
5556 case wHookshot:
5557 def = defend(wpnId, power, edefHOOKSHOT);
5558 break;
5559
5560 // Anyway...
5561 case wBomb:
5562 def = defend(wpnId, power, edefBOMB);
5563 break;
5564
5565 case wSBomb:
5566 def = defend(wpnId, power, edefSBOMB);
5567 break;
5568
5569 case wArrow:
5570 def = defend(wpnId, power, edefARROW);
5571 break;
5572
5573 case wFire:
5574 def = defend(wpnId, power, edefFIRE);
5575 break;
5576
5577 case wWand:
5578 def = defend(wpnId, power, edefWAND);
5579 break;
5580
5581 case wMagic:
5582 def = defend(wpnId, power, edefMAGIC);
5583 break;
5584
5585 case wHammer:
5586 def = defend(wpnId, power, edefHAMMER);
5587 break;
5588
5589 case wSword:
5590 def = defend(wpnId, power, edefSWORD);
5591 break;
5592
5593 case wBeam:
5594 def = defend(wpnId, power, edefBEAM);
5595 break;
5596
5597 case wRefBeam:
5598 def = defend(wpnId, power, edefREFBEAM);
5599 break;
5600
5601 case wRefMagic:
5602 def = defend(wpnId, power, edefREFMAGIC);
5603 break;
5604
5605 case wRefFireball:
5606 def = defend(wpnId, power, edefREFBALL);
5607 break;
5608
5609 case wRefRock:
5610 def = defend(wpnId, power, edefREFROCK);
5611 break;
5612
5613 case wStomp:
5614 def = defend(wpnId, power, edefSTOMP);
5615 break;
5616
5617 case wCByrna:
5618 def = defend(wpnId, power, edefBYRNA);
5619 break;
5620
5621 case wScript1:
5622 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
5623 else def = defend(wpnId, power, edefSCRIPT);
5624 break;
5625
5626 case wScript2:
5627 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
5628 else def = defend(wpnId, power, edefSCRIPT);
5629 break;
5630
5631 case wScript3:
5632 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
5633 else def = defend(wpnId, power, edefSCRIPT);
5634 break;
5635
5636 case wScript4:
5637 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
5638 else def = defend(wpnId, power, edefSCRIPT);
5639 break;
5640
5641 case wScript5:
5642 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
5643 else def = defend(wpnId, power, edefSCRIPT);
5644 break;
5645
5646 case wScript6:
5647 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
5648 else def = defend(wpnId, power, edefSCRIPT);
5649 break;
5650
5651 case wScript7:
5652 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
5653 else def = defend(wpnId, power, edefSCRIPT);
5654 break;
5655
5656 case wScript8:
5657 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
5658 else def = defend(wpnId, power, edefSCRIPT);
5659 break;
5660
5661 case wScript9:
5662 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
5663 else def = defend(wpnId, power, edefSCRIPT);
5664 break;
5665
5666 case wScript10:
5667 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
5668 else def = defend(wpnId, power, edefSCRIPT);
5669 break;
5670
5671 case wWhistle:
5672 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
5673 else break;
5674 break;
5675
5676
5677 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
5678 //Probably best to do this from the qest file, loading the values of Script(generic) into each
5679 //of the ten if the quest version is lower than N.
5680 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
5681 //such as bool UseSeparatedScriptDefences. hah.
5682 default:
5683 //if(wpnId>=wScript1 && wpnId<=wScript10)
5684 // {
5685 // def = defend(wpnId, power, edefSCRIPT);
5686 // }
5687 // }
5688
5689 break;
5690 }
5691
5692 return def;
5693 }
5694
5695 // take damage or ignore it
5696 // -1: damage (if any) dealt
5697 // 1: blocked
5698 // 0: weapon passes through unhindered
5699 127704 int32_t enemy::takehit(weapon *w)
5700 {
5701
2/4
✓ Branch 0 taken 127704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127704 times.
127704 if(fallclk||drownclk) return 0;
5702 127704 int32_t wpnId = w->id;
5703 //al_trace("takehit() wpnId is %d\n",wpnId);
5704 //if ( wpnId == wWhistle ) al_trace("Whistle weapon in %s\n", "takehit");
5705 127704 int32_t power = w->power;
5706 127704 int32_t wpnx = w->x;
5707 127704 int32_t wpny = w->y;
5708 127704 int32_t enemyHitWeapon = w->parentitem;
5709 int32_t wpnDir;
5710 127704 int32_t parent_item = w->parentitem;
5711
5712 //if ( parent_item > -1 )
5713 //{
5714 // if ( itemsbuf[parent_item].useweapon > 0 /*&& wpnId != wWhistle*/ )
5715 // {
5716 // wpnId = itemsbuf[parent_item].useweapon;
5717 // }
5718
5719 //}
5720 //if ( parent_item == -1 && w->ScriptGenerated )
5721 //{
5722 // if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
5723 // {
5724 // wpnId = w->useweapon;
5725 // }
5726
5727 //}
5728 //al_trace("takehit wpnId is: %d\n",wpnId);
5729
5730 //Shoud be set from idata from the weapon::weaon constructor. -Z
5731
1/2
✓ Branch 0 taken 127704 times.
✗ Branch 1 not taken.
127704 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
5732 {
5733 wpnId = w->useweapon;
5734 }
5735
5736 //al_trace("takehit() useweapon is %d\n",itemsbuf[parent_item].useweapon);
5737
5738 //Weapon Editor -Z
5739
5740
5741 // If it's a boomerang that just bounced, use the opposite direction;
5742 // otherwise, it might bypass a shield. This probably won't handle
5743 // every case correctly, but it's better than having shields simply
5744 // not work against boomerangs.
5745
8/8
✓ Branch 0 taken 14581 times.
✓ Branch 1 taken 113123 times.
✓ Branch 2 taken 9126 times.
✓ Branch 3 taken 5455 times.
✓ Branch 4 taken 8764 times.
✓ Branch 5 taken 362 times.
✓ Branch 6 taken 2032 times.
✓ Branch 7 taken 6732 times.
127704 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
5746 6732 wpnDir = oppositeDir[w->dir];
5747 else
5748 120972 wpnDir = w->dir;
5749
5750
5/8
✓ Branch 0 taken 127704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127704 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 127704 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1054 times.
✓ Branch 7 taken 126650 times.
127704 if(dying || clk<0 || hclk>0 || superman)
5751 {
5752 1054 return 0;
5753 }
5754
5755 //Prevent boomerang from writing to hitby[] for more than one frame.
5756 //This also prevents stunlock.
5757 //if ( stunclk > 0 ) return 0;
5758 //this needs a rule for boomerangs that cannot stunlock!
5759 //further, bouncing weapons should probably SFX_CHINK and bounce here.
5760 //sigh.
5761
5762 126650 int32_t ret = -1;
5763
5764 // This obscure quest rule...
5765
5/6
✓ Branch 0 taken 74238 times.
✓ Branch 1 taken 52412 times.
✓ Branch 2 taken 74110 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 74110 times.
126650 if(get_bit(quest_rules,qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
5766 {
5767 double _MSVC2022_tmp1, _MSVC2022_tmp2;
5768 128 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
5769 128 wpnDir=zc_oldrand()&3;
5770
5771
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 53 times.
128 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
5772 {
5773 53 wpnDir=down;
5774 53 }
5775
4/4
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 36 times.
75 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
5776 {
5777 36 wpnDir=right;
5778 36 }
5779
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 7 times.
39 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
5780 {
5781 7 wpnDir=up;
5782 7 }
5783 else
5784 {
5785 32 wpnDir=left;
5786 }
5787 128 }
5788
5789 126650 int32_t xdir = dir;
5790 126650 shieldCanBlock=false;
5791
5792 //if (family==eeFLOAT && flags&(inv_front|inv_back_inv_left|inv_right)) xdir=down;
5793
4/4
✓ Branch 0 taken 126262 times.
✓ Branch 1 taken 388 times.
✓ Branch 2 taken 89 times.
✓ Branch 3 taken 126173 times.
127444 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
5794
10/10
✓ Branch 0 taken 10809 times.
✓ Branch 1 taken 10720 times.
✓ Branch 2 taken 14193 times.
✓ Branch 3 taken 122700 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 122644 times.
✓ Branch 6 taken 982 times.
✓ Branch 7 taken 121662 times.
✓ Branch 8 taken 794 times.
✓ Branch 9 taken 120868 times.
126262 || ((flags&inv_front && wpnDir==(xdir^down)) || (flags&inv_back && wpnDir==(xdir^up)) || (flags&inv_left && wpnDir==(xdir^left)) || (flags&inv_right && wpnDir==(xdir^right))))
5795 )
5796 // The hammer should already be dealt with by subclasses (Walker etc.)
5797 {
5798
9/9
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 3465 times.
✓ Branch 4 taken 245 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 497 times.
✓ Branch 8 taken 394 times.
26834 switch(wpnId)
5799 {
5800 // Weapons which shields protect against
5801 case wSword:
5802 case wWand:
5803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3465 times.
3465 if(Hero.getCharging()>0)
5804 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
5805
5806 [[fallthrough]];
5807 case wHookshot:
5808 case wHSHandle:
5809 case wBrang:
5810 3647 shieldCanBlock=true;
5811 3892 break;
5812
5813 case wBeam:
5814 case wRefBeam:
5815 // Mirror shielded enemies!
5816 #if 0
5817 if(false /*flags2&guy_mirror*/ && !get_bit(quest_rules,qr_SWORDMIRROR))
5818 {
5819 if(wpnId>wEnemyWeapons)
5820 return 0;
5821
5822 sfx(WAV_CHINK,pan(int32_t(x)));
5823 return 1;
5824 }
5825
5826 #endif
5827
5828 [[fallthrough]];
5829 case wRefRock:
5830 case wRefFireball:
5831 case wMagic:
5832 #if 0
5833 if(false /*flags2&guy_mirror*/ && (wpnId!=wRefRock || get_bit(quest_rules,qr_REFLECTROCKS)))
5834 {
5835 sfx(WAV_CHINK,pan(int32_t(x)));
5836 return 3;
5837 }
5838
5839 #endif
5840
5841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 257 times.
257 if(wpnId>wEnemyWeapons)
5842 return 0;
5843
5844 [[fallthrough]];
5845 default:
5846 754 shieldCanBlock=true;
5847 754 break;
5848
5849 // Bombs
5850 case wSBomb:
5851 case wBomb:
5852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!get_bit(quest_rules,qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
5853 else if (!get_bit(quest_rules,qr_BOMBSPIERCESHIELD))
5854 {
5855 sfx(WAV_CHINK,pan(int32_t(x)));
5856 return 0;
5857 }
5858 else break;
5859
5860 // Weapons which ignore shields
5861 case wWhistle:
5862 case wHammer:
5863 1 break;
5864
5865 // Weapons which shouldn't be removed by shields
5866 case wLitBomb:
5867 case wLitSBomb:
5868 case wWind:
5869 case wPhantom:
5870 case wSSparkle:
5871 case wBait:
5872 416 return 0;
5873
5874 [[fallthrough]];
5875 case wFire:
5876 #if 0
5877 if(false /*flags2&guy_mirror*/)
5878 {
5879 sfx(WAV_CHINK,pan(int32_t(x)));
5880 return 1;
5881 }
5882
5883 #endif
5884 ;
5885 394 }
5886 4796 }
5887
5888
7/8
✓ Branch 0 taken 62573 times.
✓ Branch 1 taken 42175 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6129 times.
✓ Branch 5 taken 14566 times.
✓ Branch 6 taken 89 times.
✓ Branch 7 taken 356 times.
126052 switch(wpnId)
5889 {
5890 case wWhistle: //No longer completely ignore whistle weapons! -Z
5891 {
5892
5893
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 164 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
164 if ( ((itemsbuf[parent_item].flags & ITEM_FLAG2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
5894 {
5895 //al_trace("Whistle weapon in %s\n", "takehit flag == 0");
5896 164 return 0; break;
5897 }
5898 else
5899 {
5900 w->power = power = itemsbuf[parent_item].misc5;
5901
5902 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, w);
5903
5904 if(def <= 0)
5905 {
5906 if ( def == -2 ) hp -= hp;
5907 else hp -= power;
5908 return def;
5909 }
5910 break;
5911 }
5912 break;
5913 }
5914
5915 case wPhantom:
5916 return 0;
5917
5918 case wLitBomb:
5919 case wLitSBomb:
5920 case wBait:
5921 case wWind:
5922 case wSSparkle:
5923 62573 return 0;
5924
5925 case wFSparkle:
5926
5927 // Only take sparkle damage if the sparkle's parent item is not
5928 // defended against.
5929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6129 times.
6129 if(enemyHitWeapon > -1)
5930 {
5931 6129 int32_t p = 0;
5932 6129 int32_t f = itemsbuf[enemyHitWeapon].family;
5933
5934
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6129 times.
6129 switch(f)
5935 {
5936 case itype_arrow:
5937 if(!candamage(p, edefARROW, w->unblockable)) return 0;
5938
5939 break;
5940
5941 case itype_cbyrna:
5942 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
5943
5944 break;
5945
5946 case itype_brang:
5947
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 5907 times.
6129 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
5948
5949 222 break;
5950
5951 default:
5952 return 0;
5953 }
5954 222 }
5955
5956 222 wpnId = wSword;
5957 222 power = game->get_hero_dmgmult()>>1;
5958 222 goto fsparkle;
5959 break;
5960
5961 case wBrang:
5962 {
5963 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
5964 14566 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, w);
5965 //preventing stunlock might be best, here. -Z
5966
2/2
✓ Branch 0 taken 3640 times.
✓ Branch 1 taken 10926 times.
14566 if(def >= 0) return def;
5967
5968 // Not hurt by 0-damage weapons
5969
2/2
✓ Branch 0 taken 1866 times.
✓ Branch 1 taken 9060 times.
10926 if(!(flags & guy_bhit))
5970 {
5971 9060 stunclk=160;
5972
5973
3/4
✓ Branch 0 taken 9060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1047 times.
✓ Branch 3 taken 8013 times.
9060 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
5974 {
5975
1/2
✓ Branch 0 taken 1047 times.
✗ Branch 1 not taken.
1047 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
5976 1047 goto hitclock;
5977 }
5978
5979 8013 break;
5980 }
5981
5982
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 1511 times.
1866 if(!power)
5983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1511 times.
1511 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
5984 else
5985 355 hp-=power;
5986
5987 1866 goto hitclock;
5988 }
5989
5990 case wHookshot:
5991 {
5992 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
5993 89 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, w);
5994
5995
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 68 times.
89 if(def >= 0) return def;
5996
5997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
5998
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
68 if(swgrab || !(flags & guy_bhit))
5999 {
6000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(!swgrab)
6001 68 stunclk=160;
6002
6003
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
68 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
6004 {
6005 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
6006 goto hitclock;
6007 }
6008
6009 68 break;
6010 }
6011
6012 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
6013 else
6014 hp-=power;
6015
6016 goto hitclock;
6017 }
6018 break;
6019
6020 case wHSHandle:
6021 {
6022
3/4
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 277 times.
356 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & ITEM_FLAG1)
6023 79 return 0;
6024
6025
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
277 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
6026
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
6027
6028 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
6029
5/8
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 210 times.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 67 times.
332 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
6030
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 55 times.
✓ Branch 5 taken 62 times.
67 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(inv_back|inv_front|inv_left|inv_right))))
6031 62 return 0;
6032
6033 425 power = game->get_hero_dmgmult();
6034 647 }
6035
6036 fsparkle:
6037
6038 [[fallthrough]];
6039 default:
6040 // Work out the defenses!
6041 {
6042 42402 int32_t def = defenditemclassNew(wpnId, &power, w);
6043
6044
2/2
✓ Branch 0 taken 11833 times.
✓ Branch 1 taken 30569 times.
42402 if(def >= 0)
6045 11833 return def;
6046
2/2
✓ Branch 0 taken 30419 times.
✓ Branch 1 taken 150 times.
30569 else if(def == -2)
6047 {
6048 150 ret = 0;
6049 150 }
6050 }
6051
6052
2/2
✓ Branch 0 taken 30567 times.
✓ Branch 1 taken 2 times.
61138 if(!power)
6053 {
6054
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
6055 2 hp-=1;
6056 else
6057 {
6058 // Don't make a long chain of 'stun' hits
6059 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
6060 return 1;
6061
6062
6063 if(!switch_hooked)
6064 stunclk=160;
6065 break;
6066 }
6067 2 }
6068 30567 else hp-=power;
6069
6070 hitclock:
6071 33486 hclk=33;
6072
6073 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
6074
2/2
✓ Branch 0 taken 15782 times.
✓ Branch 1 taken 17704 times.
33486 if((dir&2)==(w->dir&2))
6075 {
6076 17704 sclk=(w->dir<<8)+16;
6077 17704 }
6078 33486 }
6079
6080
5/6
✓ Branch 0 taken 30641 times.
✓ Branch 1 taken 10926 times.
✓ Branch 2 taken 1962 times.
✓ Branch 3 taken 39605 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1962 times.
41567 if(((wpnId==wBrang) || (get_bit(quest_rules,qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
6081 {
6082 1962 fading=fade_blue_poof;
6083 1962 }
6084
6085
6086 /*
6087 if( hitsfx > 0 ) //user set hit sound.
6088 {
6089 if ( !dying ) //Don't play the hit sound when dying.
6090 sfx(hitsfx, pan(int32_t(x)));
6091 }
6092 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play this one if the user sets a custom sound!
6093 */
6094 /*
6095 if( hitsfx > 0 ) //A sound is set.
6096 {
6097 if ( !dying ) //Don't play the hit sound when dying.
6098 sfx(hitsfx, pan(int32_t(x)));
6099 }
6100 */
6101
6/6
✓ Branch 0 taken 40561 times.
✓ Branch 1 taken 1006 times.
✓ Branch 2 taken 34206 times.
✓ Branch 3 taken 6355 times.
✓ Branch 4 taken 1328 times.
✓ Branch 5 taken 32878 times.
41567 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
6102 {
6103
1/2
✓ Branch 0 taken 2334 times.
✗ Branch 1 not taken.
2334 if( hitsfx > 0 ) //user-set hit sound.
6104 {
6105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2334 times.
2334 if (!dying) //don't play the hit sound on death! -Z
6106 2334 sfx(hitsfx, pan(int32_t(x)));
6107 2334 }
6108 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
6109 2334 }
6110 else //2.50.2 or earlier
6111 {
6112 39233 sfx(WAV_EHIT, pan(int32_t(x)));
6113 39233 sfx(hitsfx, pan(int32_t(x)));
6114 }
6115
2/2
✓ Branch 0 taken 41564 times.
✓ Branch 1 taken 3 times.
41567 if(family==eeGUY)
6116 3 sfx(WAV_EDEAD, pan(int32_t(x)));
6117
6118 // Penetrating weapons
6119
4/4
✓ Branch 0 taken 41120 times.
✓ Branch 1 taken 447 times.
✓ Branch 2 taken 36482 times.
✓ Branch 3 taken 5085 times.
41567 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
6120 {
6121 5085 int32_t item=enemyHitWeapon;
6122
6123
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 4759 times.
5085 if(wpnId==wArrow)
6124 {
6125 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
6126
5/6
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 199 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
326 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG1) && (itemsbuf[parent_item].family == itype_arrow))
6127 59 return 0;
6128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 else if(get_bit(quest_rules,qr_ARROWS_ALWAYS_PENETRATE)) return 0;
6129 //if(item<0)
6130 else
6131 267 item=current_item_id(itype_arrow);
6132 267 }
6133
6134 else
6135 {
6136
6137 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
6138
2/6
✓ Branch 0 taken 4759 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4759 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4759 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG3) && (itemsbuf[parent_item].family == itype_sword))
6139 return 0;
6140
6141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4759 times.
4759 else if(get_bit(quest_rules,qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
6142 else
6143 //if(item<0)
6144 4759 item=current_item_id(itype_sword);
6145 }
6146 5026 }
6147
6148 41508 return ret;
6149 127316 }
6150
6151 21850068 bool enemy::dont_draw()
6152 {
6153
6/6
✓ Branch 0 taken 21749299 times.
✓ Branch 1 taken 100769 times.
✓ Branch 2 taken 21678392 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 30972 times.
✓ Branch 5 taken 21718327 times.
21850068 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
6154 131741 return true;
6155
6156
2/2
✓ Branch 0 taken 213288 times.
✓ Branch 1 taken 21505039 times.
21718327 if(flags&guy_invisible)
6157 213288 return true;
6158
6159
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 21504607 times.
✓ Branch 2 taken 432 times.
✗ Branch 3 not taken.
21505039 if(flags&lens_only && !lensclk)
6160 return true;
6161
6162
3/8
✓ Branch 0 taken 45951 times.
✓ Branch 1 taken 21459088 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45951 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
21505039 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) &&
6163 !((flags&lens_only) && (get_bit(quest_rules,qr_LENSSEESENEMIES) || (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5))))
6164 return true;
6165
6166 21505039 return false;
6167 21850068 }
6168
6169 #define DRAW_NORMAL 2
6170 #define DRAW_CLOAKED 1
6171 #define DRAW_INVIS 0
6172 // base drawing function to be used by all derived classes instead of
6173 // sprite::draw()
6174 18926406 void enemy::draw(BITMAP *dest)
6175 {
6176
6/6
✓ Branch 0 taken 18648620 times.
✓ Branch 1 taken 277786 times.
✓ Branch 2 taken 18565970 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 134965 times.
✓ Branch 5 taken 18513655 times.
18926406 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
6177 412751 return;
6178
2/2
✓ Branch 0 taken 1432295 times.
✓ Branch 1 taken 17081360 times.
18513655 if(flags&guy_invisible)
6179 1432295 return;
6180
3/8
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 17055102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17081360 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) && !(flags&lens_only))
6181 return;
6182
6183 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
6184 // be cloaked if they have "invisible displays as cloaked" checked.
6185
6186 17081360 byte canSee = DRAW_NORMAL;
6187 //Enemy specific stuff
6188
1/2
✓ Branch 0 taken 17081360 times.
✗ Branch 1 not taken.
17081360 if ( editorflags & ENEMY_FLAG1 )
6189 {
6190 canSee = DRAW_INVIS;
6191 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
6192 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
6193 {
6194 if (game->item[dmisc13])
6195 {
6196 canSee = DRAW_NORMAL;
6197 }
6198 //else if ( lensclk && getlensid.flags SHOWINVIS )
6199 //{
6200 //
6201 //}
6202 //else
6203 //{
6204 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
6205 // //otherwisem invisible
6206 //}
6207 }
6208 }
6209 //Room specific
6210
2/2
✓ Branch 0 taken 16993114 times.
✓ Branch 1 taken 88246 times.
17081360 if (tmpscr->flags3&fINVISROOM)
6211 {
6212
4/6
✓ Branch 0 taken 88246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15679 times.
✓ Branch 3 taken 72567 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15679 times.
103925 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
6213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15679 times.
15679 !((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
6214 88246 }
6215 //Lens check
6216
2/2
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 17055102 times.
17081360 if (lensclk)
6217 {
6218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26258 if((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(flags&lens_only))
6219 {
6220 if (canSee == DRAW_NORMAL)
6221 {
6222 if (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) canSee = DRAW_CLOAKED;
6223 else canSee = DRAW_INVIS; //Should never happen cause dont_draw should catch this, but just in case.
6224 }
6225 }
6226
2/2
✓ Branch 0 taken 25826 times.
✓ Branch 1 taken 432 times.
26258 if(flags&lens_only)
6227 {
6228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
6229 432 }
6230 26258 }
6231 else
6232 {
6233
2/2
✓ Branch 0 taken 16981686 times.
✓ Branch 1 taken 73416 times.
17055102 if(flags&lens_only)
6234 73416 canSee = DRAW_INVIS;
6235 }
6236
3/4
✓ Branch 0 taken 73416 times.
✓ Branch 1 taken 17007944 times.
✓ Branch 2 taken 73416 times.
✗ Branch 3 not taken.
17081360 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
6237
3/4
✓ Branch 0 taken 16992265 times.
✓ Branch 1 taken 89095 times.
✓ Branch 2 taken 16992265 times.
✗ Branch 3 not taken.
17081360 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
6238
6239
2/2
✓ Branch 0 taken 17007944 times.
✓ Branch 1 taken 73416 times.
17081360 if (canSee == DRAW_INVIS)
6240 73416 return;
6241
6242
3/4
✓ Branch 0 taken 17007802 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17007802 times.
17007944 if(fallclk||drownclk)
6243 {
6244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if (canSee == DRAW_CLOAKED)
6245 {
6246 sprite::drawcloaked(dest);
6247 }
6248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if (canSee == DRAW_NORMAL)
6249 {
6250 142 sprite::draw(dest);
6251 142 }
6252 142 return;
6253 }
6254 17007802 int32_t cshold=cs;
6255
6256
2/2
✓ Branch 0 taken 391623 times.
✓ Branch 1 taken 16616179 times.
17007802 if(dying)
6257 {
6258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391623 times.
391623 if(clk2>=19)
6259 {
6260 if(!(clk2&2))
6261 {
6262 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
6263 if (canSee == DRAW_CLOAKED)
6264 {
6265 sprite::drawcloaked(dest);
6266 }
6267 else if (canSee == DRAW_NORMAL)
6268 {
6269 sprite::draw(dest);
6270 }
6271 }
6272 return;
6273 }
6274
6275 391623 flip = 0;
6276 391623 tile = wpnsbuf[spr_death].tile;
6277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391623 times.
391623 if ( do_animation )
6278 {
6279 391623 int32_t offs = 0;
6280
2/2
✓ Branch 0 taken 386816 times.
✓ Branch 1 taken 4807 times.
391623 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
6281 {
6282
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 239 times.
4807 if(clk2 > 2)
6283 {
6284 239 spr_death_anim_clk=0;
6285 239 clk2=1;
6286
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 235 times.
239 if(hp > -1000)
6287 235 death_sfx();
6288 239 }
6289
4/4
✓ Branch 0 taken 4472 times.
✓ Branch 1 taken 335 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4456 times.
4807 if(clk2==1 && spr_death_anim_clk>-1)
6290 {
6291 4456 ++clk2;
6292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
4456 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
6293
1/2
✓ Branch 0 taken 4456 times.
✗ Branch 1 not taken.
4456 spr_death_anim_frm *= zc_max(1,txsz);
6294 4456 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
6295
2/2
✓ Branch 0 taken 4383 times.
✓ Branch 1 taken 73 times.
4456 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6296
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
✓ Branch 2 taken 4456 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✓ Branch 5 taken 4217 times.
4456 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
6297 {
6298 239 spr_death_anim_clk=-1;
6299 239 clk2=1;
6300 239 }
6301 4456 }
6302 4807 tile += spr_death_anim_frm;
6303 4807 }
6304
2/2
✓ Branch 0 taken 6579 times.
✓ Branch 1 taken 380237 times.
386816 else if(BSZ)
6305 {
6306
2/2
✓ Branch 0 taken 5178 times.
✓ Branch 1 taken 1401 times.
6579 offs = zc_min((15-clk2)/3,4);
6307 6579 }
6308
4/4
✓ Branch 0 taken 253528 times.
✓ Branch 1 taken 126709 times.
✓ Branch 2 taken 126598 times.
✓ Branch 3 taken 126930 times.
380237 else if(clk2>6 && clk2<=12)
6309 {
6310 126930 offs = 1;
6311 126930 }
6312
6313
2/2
✓ Branch 0 taken 259056 times.
✓ Branch 1 taken 132567 times.
391623 if(offs)
6314 {
6315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132567 times.
132567 offs *= zc_max(1,txsz);
6316 132567 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
6317
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 132519 times.
132567 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6318 132567 }
6319 391623 tile += offs;
6320 391623 }
6321
6322
6/6
✓ Branch 0 taken 386816 times.
✓ Branch 1 taken 4807 times.
✓ Branch 2 taken 380237 times.
✓ Branch 3 taken 6579 times.
✓ Branch 4 taken 63806 times.
✓ Branch 5 taken 316431 times.
391623 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
6323 75192 cs = wpnsbuf[spr_death].csets&15;
6324 else
6325 316431 cs = (((clk2+5)>>1)&3)+6;
6326 391623 }
6327
3/4
✓ Branch 0 taken 543796 times.
✓ Branch 1 taken 16072383 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 543796 times.
16616179 else if(hclk>0 && getCanFlicker())
6328 {
6329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 543796 times.
543796 if(family==eeGANON)
6330 cs=(((hclk-1)>>1)&3)+6;
6331
4/4
✓ Branch 0 taken 504043 times.
✓ Branch 1 taken 39753 times.
✓ Branch 2 taken 174114 times.
✓ Branch 3 taken 329929 times.
543796 else if(hclk<33 && !get_bit(quest_rules,qr_ENEMIESFLICKER))
6332 329929 cs=(((hclk-1)>>1)&3)+6;
6333 543796 }
6334 //draw every other frame for flickering enemies
6335
8/10
✓ Branch 0 taken 8495178 times.
✓ Branch 1 taken 8512624 times.
✓ Branch 2 taken 8495178 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461184 times.
✓ Branch 5 taken 8033994 times.
✓ Branch 6 taken 137054 times.
✓ Branch 7 taken 324130 times.
✓ Branch 8 taken 137054 times.
✗ Branch 9 not taken.
17007802 if((frame&1)==1 || !(family !=eeGANON && hclk>0 && get_bit(quest_rules,qr_ENEMIESFLICKER) && getCanFlicker()))
6336 {
6337
2/2
✓ Branch 0 taken 15508 times.
✓ Branch 1 taken 16855240 times.
16870748 if (canSee == DRAW_CLOAKED)
6338 {
6339 15508 sprite::drawcloaked(dest);
6340 15508 }
6341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16855240 times.
16855240 else if (canSee == DRAW_NORMAL)
6342 {
6343
1/2
✓ Branch 0 taken 16855240 times.
✗ Branch 1 not taken.
16855240 if ( frozenclock < 0 )
6344 {
6345 if ( frozentile > 0 ) tile = frozentile;
6346 loadpalset(csBOSS,frozencset);
6347 }
6348 16855240 sprite::draw(dest);
6349 16855240 }
6350 16870748 }
6351 17007802 cs=cshold;
6352 18926406 }
6353
6354 //old zc bosses
6355 17391598 void enemy::drawzcboss(BITMAP *dest)
6356 {
6357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17391598 times.
17391598 if(dont_draw())
6358 return;
6359
6360 17391598 int32_t cshold=cs;
6361
6362
2/2
✓ Branch 0 taken 352019 times.
✓ Branch 1 taken 17039579 times.
17391598 if(dying)
6363 {
6364
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 349499 times.
352019 if(clk2>=19)
6365 {
6366
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 1260 times.
2520 if(!(clk2&2))
6367 1260 sprite::drawzcboss(dest);
6368
6369 2520 return;
6370 }
6371
6372 349499 flip = 0;
6373 349499 tile = wpnsbuf[spr_death].tile;
6374
6375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 349499 times.
349499 if ( do_animation )
6376 {
6377
2/2
✓ Branch 0 taken 347313 times.
✓ Branch 1 taken 2186 times.
349499 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
6378 {
6379
2/2
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 2 times.
2186 if(clk2 > 2)
6380 {
6381 2 spr_death_anim_clk=0;
6382 2 clk2=1;
6383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(hp > -1000)
6384 2 death_sfx();
6385 2 }
6386
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 91 times.
✓ Branch 3 taken 2 times.
2186 if(clk2==1 && spr_death_anim_clk>-1)
6387 {
6388 2 ++clk2;
6389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
6390
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 spr_death_anim_frm *= zc_max(1,txsz);
6391 2 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
6392
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6393
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
6394 {
6395 spr_death_anim_clk=-1;
6396 clk2=1;
6397 }
6398 2 }
6399 2186 tile += spr_death_anim_frm;
6400 2186 }
6401
2/2
✓ Branch 0 taken 6579 times.
✓ Branch 1 taken 340734 times.
347313 else if(BSZ)
6402
2/2
✓ Branch 0 taken 5178 times.
✓ Branch 1 taken 1401 times.
6579 tile += zc_min((15-clk2)/3,4);
6403
4/4
✓ Branch 0 taken 227078 times.
✓ Branch 1 taken 113656 times.
✓ Branch 2 taken 113399 times.
✓ Branch 3 taken 113679 times.
340734 else if(clk2>6 && clk2<=12)
6404 113679 ++tile;
6405 349499 }
6406
6407
6/6
✓ Branch 0 taken 347313 times.
✓ Branch 1 taken 2186 times.
✓ Branch 2 taken 340734 times.
✓ Branch 3 taken 6579 times.
✓ Branch 4 taken 60782 times.
✓ Branch 5 taken 279952 times.
349499 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
6408 69547 cs = wpnsbuf[spr_death].csets&15;
6409 else
6410 279952 cs = (((clk2+5)>>1)&3)+6;
6411 349499 }
6412
2/2
✓ Branch 0 taken 16506809 times.
✓ Branch 1 taken 532770 times.
17039579 else if(hclk>0)
6413 {
6414
2/2
✓ Branch 0 taken 1944 times.
✓ Branch 1 taken 530826 times.
532770 if(family==eeGANON)
6415 1944 cs=(((hclk-1)>>1)&3)+6;
6416
4/4
✓ Branch 0 taken 496294 times.
✓ Branch 1 taken 34532 times.
✓ Branch 2 taken 110465 times.
✓ Branch 3 taken 385829 times.
530826 else if(hclk<33 && !get_bit(quest_rules,qr_ENEMIESFLICKER))
6417 385829 cs=(((hclk-1)>>1)&3)+6;
6418 532770 }
6419
6420
2/4
✓ Branch 0 taken 72353 times.
✓ Branch 1 taken 17316725 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17389078 if((tmpscr->flags3&fINVISROOM) &&
6421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72353 times.
72353 !(current_item(itype_amulet)) &&
6422 !(get_bit(quest_rules,qr_LENSSEESENEMIES) &&
6423 lensclk) && family!=eeGANON)
6424 {
6425 sprite::drawcloaked(dest);
6426 }
6427 else
6428 {
6429
6/6
✓ Branch 0 taken 17375414 times.
✓ Branch 1 taken 13664 times.
✓ Branch 2 taken 864561 times.
✓ Branch 3 taken 16510853 times.
✓ Branch 4 taken 705056 times.
✓ Branch 5 taken 159505 times.
17389078 if(family !=eeGANON && hclk>0 && get_bit(quest_rules,qr_ENEMIESFLICKER))
6430 {
6431
2/2
✓ Branch 0 taken 15820 times.
✓ Branch 1 taken 143685 times.
159505 if((frame&1)==1)
6432 143685 sprite::drawzcboss(dest);
6433 159505 }
6434 else
6435 17229573 sprite::drawzcboss(dest);
6436 }
6437
6438 17389078 cs=cshold;
6439 17391598 }
6440
6441
6442 // similar to the overblock function--can do up to a 32x32 sprite
6443 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
6444 113584 void enemy::drawblock(BITMAP *dest,int32_t mask)
6445 {
6446 113584 int32_t thold=tile;
6447 113584 int32_t t1=tile;
6448 113584 int32_t t2=tile+20;
6449 113584 int32_t t3=tile+1;
6450 113584 int32_t t4=tile+21;
6451
6452
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 113584 times.
113584 switch(mask)
6453 {
6454 case 1:
6455 enemy::drawzcboss(dest);
6456 break;
6457
6458 case 3:
6459 if(flip&2)
6460 zc_swap(t1,t2);
6461
6462 tile=t1;
6463 enemy::drawzcboss(dest);
6464 tile=t2;
6465 yofs+=16;
6466 enemy::drawzcboss(dest);
6467 yofs-=16;
6468 break;
6469
6470 case 5:
6471 t2=tile+1;
6472
6473 if(flip&1)
6474 zc_swap(t1,t2);
6475
6476 tile=t1;
6477 enemy::drawzcboss(dest);
6478 tile=t2;
6479 xofs+=16;
6480 enemy::drawzcboss(dest);
6481 xofs-=16;
6482 break;
6483
6484 case 15:
6485
2/2
✓ Branch 0 taken 111236 times.
✓ Branch 1 taken 2348 times.
113584 if(flip&1)
6486 {
6487 2348 zc_swap(t1,t3);
6488 2348 zc_swap(t2,t4);
6489 2348 }
6490
6491
1/2
✓ Branch 0 taken 113584 times.
✗ Branch 1 not taken.
113584 if(flip&2)
6492 {
6493 zc_swap(t1,t2);
6494 zc_swap(t3,t4);
6495 }
6496
6497 113584 tile=t1;
6498 113584 enemy::drawzcboss(dest);
6499 113584 tile=t2;
6500 113584 yofs+=16;
6501 113584 enemy::drawzcboss(dest);
6502 113584 yofs-=16;
6503 113584 tile=t3;
6504 113584 xofs+=16;
6505 113584 enemy::drawzcboss(dest);
6506 113584 tile=t4;
6507 113584 yofs+=16;
6508 113584 enemy::drawzcboss(dest);
6509 113584 xofs-=16;
6510 113584 yofs-=16;
6511 113584 break;
6512 }
6513
6514 113584 tile=thold;
6515 113584 }
6516
6517 4261611 void enemy::drawshadow(BITMAP *dest, bool translucent)
6518 {
6519
4/4
✓ Branch 0 taken 3916582 times.
✓ Branch 1 taken 345029 times.
✓ Branch 2 taken 430389 times.
✓ Branch 3 taken 3486193 times.
4261611 if(dont_draw() || isSideViewGravity())
6520 {
6521 775418 return;
6522 }
6523
6524
2/2
✓ Branch 0 taken 59397 times.
✓ Branch 1 taken 3426796 times.
3486193 if(dying)
6525 {
6526 59397 return;
6527 }
6528
6529
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3426796 times.
✓ Branch 2 taken 145552 times.
✓ Branch 3 taken 3281244 times.
3426796 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
6530 3426796 (darkroom))
6531 {
6532 145552 return;
6533 }
6534 else
6535 {
6536
4/4
✓ Branch 0 taken 3164030 times.
✓ Branch 1 taken 117214 times.
✓ Branch 2 taken 3155778 times.
✓ Branch 3 taken 8252 times.
3281244 if(enemycanfall(id, false) && shadowtile == 0)
6537 8252 shadowtile = wpnsbuf[spr_shadow].tile;
6538
6539
5/6
✓ Branch 0 taken 2709194 times.
✓ Branch 1 taken 572050 times.
✓ Branch 2 taken 2709194 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2591980 times.
✓ Branch 5 taken 117214 times.
3281244 if(z>0 || fakez>0 || !enemycanfall(id, false))
6540 {
6541
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 689148 times.
689264 if(!shadow_overpit(this))
6542 689148 sprite::drawshadow(dest,translucent);
6543 689264 }
6544 }
6545 4261611 }
6546
6547 67181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
6548 {
6549 67181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
6550
6551
1/2
✓ Branch 0 taken 67181 times.
✗ Branch 1 not taken.
67181 if(sub!=NULL)
6552 {
6553 67181 xofs-=mx;
6554 67181 yofs-=my;
6555 67181 enemy::draw(sub);
6556 67181 xofs+=mx;
6557 67181 yofs+=my;
6558 67181 destroy_bitmap(sub);
6559 67181 }
6560 else
6561 enemy::draw(dest);
6562 67181 }
6563
6564 // override hit detection to check for invicibility, stunned, etc
6565 52704 bool enemy::hit(sprite *s)
6566 {
6567
3/6
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52704 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 52704 times.
52704 if(!(s->scriptcoldet&1) || s->fallclk || s->drownclk) return false;
6568
6569
2/4
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52704 times.
✗ Branch 3 not taken.
52704 return (dying || hclk>0) ? false : sprite::hit(s);
6570 52704 }
6571
6572 21163961 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
6573 {
6574
4/4
✓ Branch 0 taken 20806038 times.
✓ Branch 1 taken 357923 times.
✓ Branch 2 taken 20204646 times.
✓ Branch 3 taken 601392 times.
21163961 return (dying || hclk>0) ? false : sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
6575 }
6576 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
6577 {
6578 return (dying || hclk>0) ? false : sprite::hit(tx,ty,txsz2,tysz2);
6579 }
6580
6581 5962827 bool enemy::hit(weapon *w)
6582 {
6583
4/6
✓ Branch 0 taken 5865572 times.
✓ Branch 1 taken 97255 times.
✓ Branch 2 taken 5865572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5865572 times.
5962827 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk) return false;
6584
6585
4/4
✓ Branch 0 taken 5697476 times.
✓ Branch 1 taken 168096 times.
✓ Branch 2 taken 5419009 times.
✓ Branch 3 taken 278467 times.
5865572 return (dying || hclk>0) ? false : sprite::hit(w);
6586 5962827 }
6587
6588 5501417 bool enemy::can_pitfall(bool checkspawning)
6589 {
6590
4/4
✓ Branch 0 taken 5494852 times.
✓ Branch 1 taken 6565 times.
✓ Branch 2 taken 5492063 times.
✓ Branch 3 taken 9354 times.
5501417 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
6591
2/2
✓ Branch 0 taken 5486725 times.
✓ Branch 1 taken 5338 times.
5492063 switch(guysbuf[id&0xFFF].family)
6592 {
6593 case eeAQUA:
6594 case eeDIG:
6595 case eeDONGO:
6596 case eeFAIRY:
6597 case eeGANON:
6598 case eeGHOMA:
6599 case eeGLEEOK:
6600 case eeGUY:
6601 case eeLANM:
6602 case eeMANHAN:
6603 case eeMOLD:
6604 case eeNONE:
6605 case eePATRA:
6606 case eeZORA:
6607 5338 return false; //Disallowed types
6608 default:
6609 5486725 return true;
6610 }
6611 5501417 }
6612 //Handle death
6613 15718850 void enemy::try_death(bool force_kill)
6614 {
6615
8/8
✓ Branch 0 taken 15711973 times.
✓ Branch 1 taken 6877 times.
✓ Branch 2 taken 15711971 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 16964 times.
✓ Branch 5 taken 15695007 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 16963 times.
15718850 if(!dying && (force_kill || (hp<=0 && !immortal)))
6616 {
6617 16965 std::vector<int32_t> &ev = FFCore.eventData;
6618 16965 ev.clear();
6619 16965 ev.push_back(10000);
6620 16965 ev.push_back(getUID());
6621
6622 16965 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
6623 16965 bool isSaved = !ev[0];
6624 16965 ev.clear();
6625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16965 times.
16965 if(isSaved) return;
6626
6627
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 16946 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 17 times.
16965 if(itemguy && (hasitem&2)!=0)
6628 {
6629
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 17 times.
37 for(int32_t i=0; i<items.Count(); i++)
6630 {
6631
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 17 times.
20 if(((item*)items.spr(i))->pickup&ipENEMY)
6632 {
6633
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if (!get_bit(quest_rules, qr_BROKEN_ITEM_CARRYING))
6634 {
6635 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
6636 {
6637 items.spr(i)->x = x+hxofs+(hxsz/2)-8;
6638 items.spr(i)->y = y+hyofs+(hysz/2)-10-fakez;
6639 }
6640 else
6641 {
6642 if(extend >= 3)
6643 {
6644 items.spr(i)->x = x+(txsz-1)*8;
6645 items.spr(i)->y = y-2+(tysz-1)*8;
6646 }
6647 else
6648 {
6649 items.spr(i)->x = x;
6650 items.spr(i)->y = y - 2;
6651 }
6652 }
6653 items.spr(i)->z = z;
6654 items.spr(i)->fakez = fakez;
6655 }
6656 else
6657 {
6658 17 items.spr(i)->x = x;
6659 17 items.spr(i)->y = y - 2;
6660 }
6661 17 }
6662 20 }
6663 17 }
6664
6665 16965 dying=true;
6666
6667
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 16944 times.
16965 if(fading==fade_flash_die)
6668 21 clk2=19+18*4;
6669 else
6670 {
6671 16944 clk2 = BSZ ? 15 : 19;
6672
6673
2/2
✓ Branch 0 taken 2033 times.
✓ Branch 1 taken 14911 times.
16944 if(fading!=fade_blue_poof)
6674 14911 fading=0;
6675 }
6676
6677
2/2
✓ Branch 0 taken 16946 times.
✓ Branch 1 taken 19 times.
16965 if(itemguy)
6678 {
6679 19 hasitem&=~2;
6680 19 item_set=0;
6681 19 }
6682
6683
6/6
✓ Branch 0 taken 16304 times.
✓ Branch 1 taken 661 times.
✓ Branch 2 taken 12596 times.
✓ Branch 3 taken 3708 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 12548 times.
16965 if(currscr<128 && count_enemy && !script_spawned)
6684 12548 game->guys[(currmap<<7)+currscr]-=1;
6685 16965 }
6686 15718850 }
6687
6688 // --==**==--
6689
6690 // Movement routines that can be used by derived classes as needed
6691
6692 // --==**==--
6693
6694 241875 void enemy::fix_coords(bool bound)
6695 {
6696
1/2
✓ Branch 0 taken 241875 times.
✗ Branch 1 not taken.
241875 if ((get_bit(quest_rules,qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
6697
1/2
✓ Branch 0 taken 241875 times.
✗ Branch 1 not taken.
241875 if(moveflags & FLAG_IGNORE_SCREENEDGE) bound = false;
6698
6699
6700
2/2
✓ Branch 0 taken 32007 times.
✓ Branch 1 taken 209868 times.
241875 if(bound)
6701 {
6702
1/2
✓ Branch 0 taken 209868 times.
✗ Branch 1 not taken.
209868 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
6703 {
6704
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 209868 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
209868 x=vbound(x, 0, (( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256-((txsz-1)*16)) : 240));
6705
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 209868 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
209868 y=vbound(y, 0,(( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176-((txsz-1)*16)) : 160));
6706 209868 }
6707 else
6708 {
6709 x=vbound(x, 0,240);
6710 y=vbound(y, 0,160);
6711 }
6712 209868 }
6713
6714
6/10
✓ Branch 0 taken 239917 times.
✓ Branch 1 taken 1958 times.
✓ Branch 2 taken 241875 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 241875 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 241875 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 241875 times.
241875 if(!OUTOFBOUNDS)
6715 {
6716 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
6717
6718 if(isSideViewGravity())
6719 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
6720 else
6721 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
6722 */
6723 241875 do_fix(x, 16, true);
6724
2/2
✓ Branch 0 taken 1958 times.
✓ Branch 1 taken 239917 times.
241875 if(isSideViewGravity())
6725 1958 do_fix(y,8,true);
6726 239917 else do_fix(y,16,true);
6727 241875 }
6728 241875 }
6729 5289 bool enemy::cannotpenetrate()
6730 {
6731
4/4
✓ Branch 0 taken 5191 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 5175 times.
5289 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
6732 }
6733
6734 349 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6735 {
6736 bool ok;
6737 349 int32_t dx = 0, dy = 0;
6738 349 int32_t sv = 8;
6739
6740 //Why is this here??? Why is it needed???
6741 349 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
6742
6743
8/9
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 46 times.
✓ Branch 4 taken 61 times.
✓ Branch 5 taken 53 times.
✓ Branch 6 taken 38 times.
✓ Branch 7 taken 51 times.
✗ Branch 8 not taken.
349 switch(ndir)
6744 {
6745 case 8:
6746 case up:
6747
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
41 if(canfall(id) && isSideViewGravity())
6748 return false;
6749
6750 41 dy = dy1-s;
6751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 special = (special==spw_clipbottomright)?spw_none:special;
6752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
6753 41 break;
6754
6755 case 12:
6756 case down:
6757
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
34 if(canfall(id) && isSideViewGravity())
6758 return false;
6759
6760 34 dy = dy2+s;
6761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
6762 34 break;
6763
6764 case 14:
6765 case left:
6766 25 dx = dx1-s;
6767 25 sv = ((isSideViewGravity())?7:8);
6768
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
6769
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
6770 25 break;
6771
6772 case 10:
6773 case right:
6774 46 dx = dx2+s;
6775 46 sv = ((isSideViewGravity())?7:8);
6776
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 42 times.
46 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
6777 46 break;
6778
6779 case 9:
6780 case r_up:
6781 61 dx = dx2+s;
6782 61 dy = dy1-s;
6783
3/4
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 1 times.
121 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6785 61 break;
6786
6787 case 11:
6788 case r_down:
6789 53 dx = dx2+s;
6790 53 dx = dy2+s;
6791
2/4
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
106 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6793 53 break;
6794
6795 case 13:
6796 case l_down:
6797 38 dx = dx1-s;
6798 38 dy = dy2+s;
6799
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
74 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6801 38 break;
6802
6803 case 15:
6804 case l_up:
6805 51 dx = dx1-s;
6806 51 dy = dy1-s;
6807
2/4
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
102 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6809 51 break;
6810
6811 default:
6812 db=99;
6813 return true;
6814 }
6815
6816 349 return ok;
6817 349 }
6818
6819
6820
6821
6822 // returns true if next step is ok, false if there is something there
6823 2895645 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
6824 {
6825 2895645 bool ok = false; //initialise the var, son't just declare it
6826 2895645 int32_t dx = 0, dy = 0;
6827 2895645 int32_t sv = 8;
6828 2895645 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
6829 //Why is this here??? Why is it needed???
6830 2895645 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
6831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2895645 times.
2895645 int32_t usexoffs = (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
6832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2895645 times.
2895645 int32_t useyoffs = (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
6833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2895645 times.
2895645 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
6834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2895645 times.
2895645 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
6835 2895645 bool offgrid = OFFGRID_ENEMY;
6836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2895645 times.
2895645 if(!offgrid)
6837 {
6838 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
6839
1/2
✓ Branch 0 taken 2895645 times.
✗ Branch 1 not taken.
2895645 if(usehei<16)usehei=16;
6840
1/2
✓ Branch 0 taken 2895645 times.
✗ Branch 1 not taken.
2895645 if(usewid<16)usewid=16;
6841 2895645 }
6842
9/9
✓ Branch 0 taken 533110 times.
✓ Branch 1 taken 425970 times.
✓ Branch 2 taken 472597 times.
✓ Branch 3 taken 485200 times.
✓ Branch 4 taken 223241 times.
✓ Branch 5 taken 270134 times.
✓ Branch 6 taken 249156 times.
✓ Branch 7 taken 236113 times.
✓ Branch 8 taken 124 times.
2895645 switch(ndir) //need to check every 8 pixels between two points
6843 {
6844 case 8:
6845 case up:
6846 {
6847
4/4
✓ Branch 0 taken 96108 times.
✓ Branch 1 taken 437002 times.
✓ Branch 2 taken 95327 times.
✓ Branch 3 taken 781 times.
533110 if(enemycanfall(id) && isSideViewGravity())
6848 781 return false;
6849
6850 532329 dy = dy1-s;
6851
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 532326 times.
532329 special = (special==spw_clipbottomright)?spw_none:special;
6852 532329 tries = usewid/(offgrid ? 8 : 16);
6853 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
6854
2/2
✓ Branch 0 taken 459813 times.
✓ Branch 1 taken 532329 times.
992142 for ( ; tries > 0; --tries )
6855 {
6856
2/2
✓ Branch 0 taken 71050 times.
✓ Branch 1 taken 461279 times.
532329 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
6857 532329 try_x += (offgrid ? 8 : 16);
6858
2/2
✓ Branch 0 taken 459813 times.
✓ Branch 1 taken 72516 times.
532329 if (!ok) break;
6859 459813 }
6860
2/2
✓ Branch 0 taken 459813 times.
✓ Branch 1 taken 72516 times.
532329 if(!ok) break;
6861
1/2
✓ Branch 0 taken 459813 times.
✗ Branch 1 not taken.
459813 if((usewid%16)>0) //Uneven width
6862 {
6863 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
6864 }
6865 459813 break;
6866 }
6867 case 12:
6868 case down:
6869 {
6870
4/4
✓ Branch 0 taken 106855 times.
✓ Branch 1 taken 319115 times.
✓ Branch 2 taken 105949 times.
✓ Branch 3 taken 906 times.
425970 if(enemycanfall(id) && isSideViewGravity())
6871 906 return false;
6872
6873 425064 dy = dy2+s;
6874 425064 tries = usewid/(offgrid ? 8 : 16);
6875 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
6876
2/2
✓ Branch 0 taken 349013 times.
✓ Branch 1 taken 425064 times.
774077 for ( ; tries > 0; --tries )
6877 {
6878
3/4
✓ Branch 0 taken 76001 times.
✓ Branch 1 taken 349063 times.
✓ Branch 2 taken 349063 times.
✗ Branch 3 not taken.
425064 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
6879 425064 try_x += (offgrid ? 8 : 16);
6880
2/2
✓ Branch 0 taken 349013 times.
✓ Branch 1 taken 76051 times.
425064 if (!ok) break;
6881 349013 }
6882
2/2
✓ Branch 0 taken 349013 times.
✓ Branch 1 taken 76051 times.
425064 if(!ok) break;
6883
1/2
✓ Branch 0 taken 349013 times.
✗ Branch 1 not taken.
349013 if((usewid%16)>0) //Uneven width
6884 {
6885 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
6886 }
6887 349013 break;
6888 }
6889 case 14:
6890 case left:
6891 {
6892 472597 dx = dx1-s;
6893 472597 sv = ((isSideViewGravity())?7:0);
6894
4/4
✓ Branch 0 taken 472591 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1082 times.
✓ Branch 3 taken 471509 times.
472597 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
6895 472597 tries = usehei/(offgrid ? 8 : 16);
6896 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
6897
2/2
✓ Branch 0 taken 401801 times.
✓ Branch 1 taken 472597 times.
874398 for ( ; tries > 0; --tries )
6898 {
6899
2/2
✓ Branch 0 taken 70372 times.
✓ Branch 1 taken 402225 times.
472597 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
6900 472597 try_y += (offgrid ? 8 : 16);
6901
2/2
✓ Branch 0 taken 401801 times.
✓ Branch 1 taken 70796 times.
472597 if (!ok) break;
6902 401801 }
6903
2/2
✓ Branch 0 taken 401801 times.
✓ Branch 1 taken 70796 times.
472597 if(!ok) break;
6904
1/2
✓ Branch 0 taken 401801 times.
✗ Branch 1 not taken.
401801 if((usehei%16)>0) //Uneven height
6905 {
6906 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
6907 }
6908 401801 break;
6909 }
6910 case 10:
6911 case right:
6912 {
6913 485200 dx = dx2+s;
6914 485200 sv = ((isSideViewGravity())?7:0);
6915 485200 tries = usehei/(offgrid ? 8 : 16);
6916 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
6917
2/2
✓ Branch 0 taken 415582 times.
✓ Branch 1 taken 485200 times.
900782 for ( ; tries > 0; --tries )
6918 {
6919
3/4
✓ Branch 0 taken 69211 times.
✓ Branch 1 taken 415989 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415989 times.
485200 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
6920 485200 try_y += (offgrid ? 8 : 16);
6921
2/2
✓ Branch 0 taken 415582 times.
✓ Branch 1 taken 69618 times.
485200 if (!ok) break;
6922 415582 }
6923
2/2
✓ Branch 0 taken 415582 times.
✓ Branch 1 taken 69618 times.
485200 if(!ok) break;
6924
1/2
✓ Branch 0 taken 415582 times.
✗ Branch 1 not taken.
415582 if((usehei%16)>0) //Uneven height
6925 {
6926 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
6927 }
6928 415582 break;
6929 }
6930 case 9:
6931 case r_up:
6932 {
6933 223241 dx = dx2+s;
6934 223241 dy = dy1-s;
6935 223241 int32_t tries_x = usewid/(offgrid ? 8 : 16);
6936 223241 sv = ((isSideViewGravity())?7:0);
6937
2/2
✓ Branch 0 taken 215839 times.
✓ Branch 1 taken 223241 times.
439080 for ( ; tries_x > 0; --tries_x )
6938 {
6939 223241 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6940 223241 try_y = 0;
6941
2/2
✓ Branch 0 taken 215839 times.
✓ Branch 1 taken 223241 times.
439080 for ( ; tries_y > 0; --tries_y )
6942 {
6943
4/4
✓ Branch 0 taken 220158 times.
✓ Branch 1 taken 3083 times.
✓ Branch 2 taken 217730 times.
✓ Branch 3 taken 2428 times.
440971 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
6944
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 216286 times.
217730 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
6945 223241 try_y += (offgrid ? 8 : 16);
6946
2/2
✓ Branch 0 taken 215839 times.
✓ Branch 1 taken 7402 times.
223241 if (!ok) break;
6947 215839 }
6948
2/2
✓ Branch 0 taken 215839 times.
✓ Branch 1 taken 7402 times.
223241 if (!ok) break;
6949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215839 times.
215839 if((usehei%16)>0) //Uneven height
6950 {
6951 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
6952 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
6953 }
6954 215839 try_x += (offgrid ? 8 : 16);
6955 215839 }
6956
2/2
✓ Branch 0 taken 215839 times.
✓ Branch 1 taken 7402 times.
223241 if(!ok) break;
6957
1/2
✓ Branch 0 taken 215839 times.
✗ Branch 1 not taken.
215839 if((usewid%16)>0) //Uneven width
6958 {
6959 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6960 try_y = 0;
6961 for ( ; tries_y > 0; --tries_y )
6962 {
6963 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
6964 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
6965 try_y += (offgrid ? 8 : 16);
6966 if (!ok) break;
6967 }
6968 if (!ok) break;
6969 if((usehei%16)>0) //Uneven height
6970 {
6971 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
6972 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
6973 }
6974 }
6975 215839 break;
6976 }
6977 case 11:
6978 case r_down:
6979 {
6980 270134 dx = dx2+s;
6981 270134 dx = dy2+s;
6982 270134 int32_t tries_x = usewid/(offgrid ? 8 : 16);
6983 //sv = ((isSideViewGravity())?7:0);
6984
2/2
✓ Branch 0 taken 264092 times.
✓ Branch 1 taken 270134 times.
534226 for ( ; tries_x > 0; --tries_x )
6985 {
6986 270134 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6987 270134 try_y = 0;
6988
2/2
✓ Branch 0 taken 264092 times.
✓ Branch 1 taken 270134 times.
534226 for ( ; tries_y > 0; --tries_y )
6989 {
6990
4/4
✓ Branch 0 taken 270010 times.
✓ Branch 1 taken 124 times.
✓ Branch 2 taken 264133 times.
✓ Branch 3 taken 5877 times.
534267 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
6991
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 264132 times.
264133 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
6992 270134 try_y += (offgrid ? 8 : 16);
6993
2/2
✓ Branch 0 taken 264092 times.
✓ Branch 1 taken 6042 times.
270134 if (!ok) break;
6994 264092 }
6995
2/2
✓ Branch 0 taken 264092 times.
✓ Branch 1 taken 6042 times.
270134 if (!ok) break;
6996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264092 times.
264092 if((usehei%16)>0) //Uneven height
6997 {
6998 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
6999 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
7000 }
7001 264092 try_x += (offgrid ? 8 : 16);
7002 264092 }
7003
2/2
✓ Branch 0 taken 264092 times.
✓ Branch 1 taken 6042 times.
270134 if(!ok) break;
7004
1/2
✓ Branch 0 taken 264092 times.
✗ Branch 1 not taken.
264092 if((usewid%16)>0) //Uneven width
7005 {
7006 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7007 try_y = 0;
7008 for ( ; tries_y > 0; --tries_y )
7009 {
7010 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
7011 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
7012 try_y += (offgrid ? 8 : 16);
7013 if (!ok) break;
7014 }
7015 if (!ok) break;
7016 if((usehei%16)>0) //Uneven height
7017 {
7018 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
7019 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
7020 }
7021 }
7022 264092 break;
7023 }
7024 case 13:
7025 case l_down:
7026 {
7027 249156 dx = dx1-s;
7028 249156 dy = dy2+s;
7029 249156 int32_t tries_x = usewid/(offgrid ? 8 : 16);
7030 //sv = ((isSideViewGravity())?7:0);
7031
2/2
✓ Branch 0 taken 242922 times.
✓ Branch 1 taken 249156 times.
492078 for ( ; tries_x > 0; --tries_x )
7032 {
7033 249156 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7034 249156 try_y = 0;
7035
2/2
✓ Branch 0 taken 242922 times.
✓ Branch 1 taken 249156 times.
492078 for ( ; tries_y > 0; --tries_y )
7036 {
7037
4/4
✓ Branch 0 taken 244908 times.
✓ Branch 1 taken 4248 times.
✓ Branch 2 taken 242962 times.
✓ Branch 3 taken 1946 times.
492118 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
7038
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 242931 times.
242962 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
7039 249156 try_y += (offgrid ? 8 : 16);
7040
2/2
✓ Branch 0 taken 242922 times.
✓ Branch 1 taken 6234 times.
249156 if (!ok) break;
7041 242922 }
7042
2/2
✓ Branch 0 taken 242922 times.
✓ Branch 1 taken 6234 times.
249156 if (!ok) break;
7043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 242922 times.
242922 if((usehei%16)>0) //Uneven height
7044 {
7045 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
7046 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
7047 }
7048 242922 try_x += (offgrid ? 8 : 16);
7049 242922 }
7050
2/2
✓ Branch 0 taken 242922 times.
✓ Branch 1 taken 6234 times.
249156 if(!ok) break;
7051
1/2
✓ Branch 0 taken 242922 times.
✗ Branch 1 not taken.
242922 if((usewid%16)>0) //Uneven width
7052 {
7053 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7054 try_y = 0;
7055 for ( ; tries_y > 0; --tries_y )
7056 {
7057 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
7058 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
7059 try_y += (offgrid ? 8 : 16);
7060 if (!ok) break;
7061 }
7062 if (!ok) break;
7063 if((usehei%16)>0) //Uneven height
7064 {
7065 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
7066 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
7067 }
7068 }
7069 242922 break;
7070 }
7071 case 15:
7072 case l_up:
7073 {
7074 236113 dx = dx1-s;
7075 236113 dy = dy1-s;
7076 236113 int32_t tries_x = usewid/(offgrid ? 8 : 16);
7077 236113 sv = ((isSideViewGravity())?7:0);
7078
2/2
✓ Branch 0 taken 229125 times.
✓ Branch 1 taken 236113 times.
465238 for ( ; tries_x > 0; --tries_x )
7079 {
7080 236113 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7081 236113 try_y = 0;
7082
2/2
✓ Branch 0 taken 229125 times.
✓ Branch 1 taken 236113 times.
465238 for ( ; tries_y > 0; --tries_y )
7083 {
7084
4/4
✓ Branch 0 taken 232870 times.
✓ Branch 1 taken 3243 times.
✓ Branch 2 taken 231041 times.
✓ Branch 3 taken 1829 times.
467154 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
7085
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 229587 times.
231041 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
7086 236113 try_y += (offgrid ? 8 : 16);
7087
2/2
✓ Branch 0 taken 229125 times.
✓ Branch 1 taken 6988 times.
236113 if (!ok) break;
7088 229125 }
7089
2/2
✓ Branch 0 taken 229125 times.
✓ Branch 1 taken 6988 times.
236113 if (!ok) break;
7090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 229125 times.
229125 if((usehei%16)>0) //Uneven height
7091 {
7092 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
7093 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
7094 }
7095 229125 try_x += (offgrid ? 8 : 16);
7096 229125 }
7097
2/2
✓ Branch 0 taken 229125 times.
✓ Branch 1 taken 6988 times.
236113 if(!ok) break;
7098
1/2
✓ Branch 0 taken 229125 times.
✗ Branch 1 not taken.
229125 if((usewid%16)>0) //Uneven width
7099 {
7100 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7101 try_y = 0;
7102 for ( ; tries_y > 0; --tries_y )
7103 {
7104 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
7105 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
7106 try_y += (offgrid ? 8 : 16);
7107 if (!ok) break;
7108 }
7109 if (!ok) break;
7110 if((usehei%16)>0) //Uneven height
7111 {
7112 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
7113 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
7114 }
7115 }
7116 229125 break;
7117 }
7118 default:
7119 124 db=99;
7120 124 return true;
7121 }
7122 //Z_eventlog("\n");
7123 2893834 return ok;
7124 2895645 }
7125
7126
7127 1892949 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
7128 {
7129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1892949 times.
1892949 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
7130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1892949 times.
1892949 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
7131
1/2
✓ Branch 0 taken 1892949 times.
✗ Branch 1 not taken.
1892949 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
7132
1/2
✓ Branch 0 taken 1892949 times.
✗ Branch 1 not taken.
1892949 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
7133 1892949 --usewid;
7134 1892949 --usehei;
7135 1892949 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
7136 }
7137
7138 490232 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
7139 {
7140 490232 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
7141
7142
4/4
✓ Branch 0 taken 4058 times.
✓ Branch 1 taken 486174 times.
✓ Branch 2 taken 3033 times.
✓ Branch 3 taken 1025 times.
490232 if(special==spw_clipright&&ndir==right)
7143 {
7144 1025 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
7145 1025 }
7146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490232 times.
490232 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
7147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490232 times.
490232 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
7148
1/2
✓ Branch 0 taken 490232 times.
✗ Branch 1 not taken.
490232 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
7149
1/2
✓ Branch 0 taken 490232 times.
✗ Branch 1 not taken.
490232 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
7150 490232 --usewid;
7151 490232 --usehei;
7152
2/2
✓ Branch 0 taken 262241 times.
✓ Branch 1 taken 227991 times.
490232 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
7153 }
7154
7155 46098 bool enemy::canmove(int32_t ndir, bool kb)
7156 {
7157 46098 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
7158 }
7159
7160 // 8-directional
7161 349 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
7162 {
7163 349 int32_t ndir=0;
7164
7165 // can move straight, check if it wants to turn
7166
2/2
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 8 times.
349 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
7167 {
7168
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
341 if(grumble && (zc_oldrand()&4)<grumble) //Homing
7169 {
7170 int32_t w = Lwpns.idFirst(wBait);
7171
7172 if(w>=0)
7173 {
7174 int32_t bx = Lwpns.spr(w)->x;
7175 int32_t by = Lwpns.spr(w)->y;
7176
7177 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
7178
7179 if(abs(int32_t(y)-by)>14)
7180 {
7181 if(ndir>0) // Already left or right
7182 {
7183 // Making the diagonal directions
7184 ndir += (by<y) ? 2 : 4;
7185 }
7186 else
7187 {
7188 ndir = (by<y) ? up : down;
7189 }
7190 }
7191
7192 if(canmove(ndir,special,false))
7193 {
7194 dir=ndir;
7195 return;
7196 }
7197 }
7198 }
7199
7200 // Homing added.
7201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
341 if(newhoming && (zc_oldrand()&255)<newhoming)
7202 {
7203 ndir = lined_up(8,true);
7204
7205 if(ndir>=0 && canmove(ndir,special,false))
7206 {
7207 dir=ndir;
7208 }
7209
7210 return;
7211 }
7212
7213 341 int32_t r=zc_oldrand();
7214
7215
2/4
✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 341 times.
341 if(newrate>0 && !(r%newrate))
7216 {
7217 341 ndir = ((dir+((r&64)?-1:1))&7)+8;
7218 341 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
7219
7220
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 14 times.
341 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7221 327 dir=ndir;
7222
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
14 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
7223 11 dir=ndir2;
7224
7225
3/4
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
341 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
7226 // due to numerous lost fractional components. -L
7227 {
7228 x.doFloor();
7229 y.doFloor();
7230 }
7231 341 }
7232
7233 341 return;
7234 }
7235
7236 // can't move straight, must turn
7237 8 int32_t i=0;
7238
7239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 for(; i<32; i++) // Try random dir
7240 {
7241 15 ndir=(zc_oldrand()&7)+8;
7242
7243
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
15 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7244 8 break;
7245 7 }
7246
7247
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(i==32)
7248 {
7249 for(ndir=8; ndir<16; ndir++)
7250 {
7251 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7252 goto ok;
7253 }
7254
7255 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7256 }
7257
7258 ok:
7259 8 dir=ndir;
7260 8 x.doFloor();
7261 8 y.doFloor();
7262 349 }
7263
7264 238523 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
7265 {
7266 238523 int32_t ndir=0;
7267
7268 // can move straight, check if it wants to turn
7269
2/2
✓ Branch 0 taken 224518 times.
✓ Branch 1 taken 14005 times.
238523 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
7270 {
7271
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 224518 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
224518 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
7272 {
7273 int32_t i = Lwpns.idFirst(wBait);
7274 if(i >= 0) //idfirst returns -1 if it can't find any
7275 {
7276 weapon *w = (weapon*)Lwpns.spr(i);
7277 if (get_bit(quest_rules, qr_FIND_CLOSEST_BAIT))
7278 {
7279 int32_t currentrange;
7280 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
7281 else currentrange = -1;
7282 int curid = i;
7283 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
7284 for(; i<Lwpns.Count(); ++i)
7285 {
7286 weapon *lw = (weapon*)Lwpns.spr(i);
7287 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
7288 {
7289 currentrange = distance(x, y, lw->x, lw->y);
7290 curid = i;
7291 }
7292 }
7293 i = curid;
7294 if (currentrange == -1) i = -1;
7295 }
7296 else
7297 {
7298 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
7299 }
7300 if(i>=0)
7301 {
7302 int32_t bx = Lwpns.spr(i)->x;
7303 int32_t by = Lwpns.spr(i)->y;
7304
7305 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
7306
7307 if(abs(int32_t(y)-by)>14)
7308 {
7309 if(ndir>0) // Already left or right
7310 {
7311 // Making the diagonal directions
7312 ndir += (by<y) ? 2 : 4;
7313 }
7314 else
7315 {
7316 ndir = (by<y) ? up : down;
7317 }
7318 }
7319 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7320 if(canmove(ndir,special,false))
7321 {
7322 dir=ndir;
7323 return;
7324 }
7325 }
7326 }
7327 }
7328
7329 // Homing added.
7330
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 224518 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
224518 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
7331 {
7332 ndir = lined_up(8,true);
7333 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
7334 if(ndir>=0 && canmove(ndir,special,false))
7335 {
7336 dir=ndir;
7337 }
7338
7339 return;
7340 }
7341
7342 224518 int32_t r=zc_oldrand();
7343
7344
4/4
✓ Branch 0 taken 149027 times.
✓ Branch 1 taken 75491 times.
✓ Branch 2 taken 79975 times.
✓ Branch 3 taken 69052 times.
224518 if(newrate>0 && !(r%newrate))
7345 {
7346 69052 ndir = ((dir+((r&64)?-1:1))&7)+8;
7347 69052 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
7348
7349
2/2
✓ Branch 0 taken 66852 times.
✓ Branch 1 taken 2200 times.
69052 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7350 66852 dir=ndir;
7351
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2195 times.
2200 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
7352 2195 dir=ndir2;
7353
7354
4/4
✓ Branch 0 taken 66852 times.
✓ Branch 1 taken 2200 times.
✓ Branch 2 taken 63828 times.
✓ Branch 3 taken 3024 times.
69052 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
7355 // due to numerous lost fractional components. -L
7356 {
7357 3024 x.doFloor();
7358 3024 y.doFloor();
7359 3024 }
7360 69052 }
7361
7362 224518 return;
7363 }
7364
7365 // can't move straight, must turn
7366 14005 int32_t i=0;
7367
7368
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 26101 times.
26111 for(; i<32; i++) // Try random dir
7369 {
7370 26101 ndir=(zc_oldrand()&7)+8;
7371
7372
2/2
✓ Branch 0 taken 12106 times.
✓ Branch 1 taken 13995 times.
26101 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7373 13995 break;
7374 12106 }
7375
7376
2/2
✓ Branch 0 taken 13995 times.
✓ Branch 1 taken 10 times.
14005 if(i==32)
7377 {
7378
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 for(ndir=8; ndir<16; ndir++)
7379 {
7380
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 10 times.
12 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7381 10 goto ok;
7382 2 }
7383
7384 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7385 }
7386
7387 ok:
7388 14005 dir=ndir;
7389 14005 x.doFloor();
7390 14005 y.doFloor();
7391 238523 }
7392
7393 235655 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
7394 {
7395 235655 newdir_8(newrate,newhoming,special,0,-8,15,15);
7396 235655 }
7397
7398 349 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
7399 {
7400 349 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
7401 349 }
7402
7403 // makes the enemy slide backwards when hit
7404 // sclk: first byte is clk, second byte is dir
7405 // makes the enemy slide backwards when hit
7406 // sclk: first byte is clk, second byte is dir
7407 6855408 int32_t enemy::slide()
7408 {
7409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6855408 times.
6855408 if(script_knockback_clk!=0) //scripted knockback
7410 {
7411 sclk = 0;
7412 return 1; //scripted knockback ran
7413 }
7414
5/6
✓ Branch 0 taken 43774 times.
✓ Branch 1 taken 6811634 times.
✓ Branch 2 taken 5087 times.
✓ Branch 3 taken 38687 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5087 times.
6855408 if(sclk==0 || (hp<=0 && !immortal))
7415 6816721 return 0;
7416
7417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38687 times.
38687 if(knockbackflags & FLAG_NOSLIDE)
7418 {
7419 sclk = 0;
7420 if(!OFFGRID_ENEMY)
7421 {
7422 //Fix to grid
7423 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
7424 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
7425 do_fix(x, 16, true);
7426 do_fix(y, 16, true);
7427 }
7428 return 0;
7429 }
7430
8/10
✓ Branch 0 taken 3954 times.
✓ Branch 1 taken 34733 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 3929 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 2917 times.
✓ Branch 7 taken 1012 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 25 times.
38687 if((sclk&255)==16 && (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
7431 {
7432 1012 sclk=0;
7433 1012 return 0;
7434 }
7435
7436 37675 --sclk;
7437
7438
5/5
✓ Branch 0 taken 1403 times.
✓ Branch 1 taken 4257 times.
✓ Branch 2 taken 4583 times.
✓ Branch 3 taken 12580 times.
✓ Branch 4 taken 14852 times.
37675 switch(sclk>>8)
7439 {
7440 case up:
7441 {
7442
4/4
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 3826 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 4251 times.
4257 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
7443 {
7444 6 sclk=0;
7445 6 return 0;
7446 }
7447
4/4
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 3820 times.
✓ Branch 2 taken 365 times.
✓ Branch 3 taken 66 times.
4251 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7448
7449 4185 break;
7450 }
7451 case down:
7452 {
7453
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4581 times.
4583 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
7454 {
7455 2 sclk=0;
7456 2 return 0;
7457 }
7458
4/4
✓ Branch 0 taken 581 times.
✓ Branch 1 taken 4000 times.
✓ Branch 2 taken 502 times.
✓ Branch 3 taken 79 times.
4581 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7459
7460 4502 break;
7461 }
7462 case left:
7463 {
7464
4/4
✓ Branch 0 taken 1007 times.
✓ Branch 1 taken 11573 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 12567 times.
12580 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
7465 {
7466 13 sclk=0;
7467 13 return 0;
7468 }
7469
4/4
✓ Branch 0 taken 1007 times.
✓ Branch 1 taken 11560 times.
✓ Branch 2 taken 920 times.
✓ Branch 3 taken 87 times.
12567 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
7470
7471 12480 break;
7472 }
7473 case right:
7474 {
7475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14852 times.
14852 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
7476 {
7477 sclk=0;
7478 return 0;
7479 }
7480
4/4
✓ Branch 0 taken 1959 times.
✓ Branch 1 taken 12893 times.
✓ Branch 2 taken 1826 times.
✓ Branch 3 taken 133 times.
14852 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7481 14719 break;
7482 }
7483 }
7484
7485 37289 int32_t move = knockbackSpeed;
7486
2/2
✓ Branch 0 taken 35367 times.
✓ Branch 1 taken 37289 times.
72656 while(move>0)
7487 {
7488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37289 times.
37289 int32_t thismove = zc_min(8, move);
7489 37289 move -= thismove;
7490 37289 hitdir = (sclk>>8);
7491
5/5
✓ Branch 0 taken 1403 times.
✓ Branch 1 taken 4185 times.
✓ Branch 2 taken 4502 times.
✓ Branch 3 taken 12480 times.
✓ Branch 4 taken 14719 times.
37289 switch(sclk>>8)
7492 {
7493 case up:
7494 4185 y-=thismove;
7495 4185 break;
7496
7497 case down:
7498 4502 y+=thismove;
7499 4502 break;
7500
7501 case left:
7502 12480 x-=thismove;
7503 12480 break;
7504
7505 case right:
7506 14719 x+=thismove;
7507 14719 break;
7508 }
7509
2/2
✓ Branch 0 taken 35367 times.
✓ Branch 1 taken 1922 times.
37289 if(!canmove(sclk>>8,(zfix)0,0,true))
7510 {
7511
3/3
✓ Branch 0 taken 754 times.
✓ Branch 1 taken 1165 times.
✓ Branch 2 taken 3 times.
1922 switch(sclk>>8)
7512 {
7513 case up:
7514 case down:
7515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 754 times.
754 if(y < 0)
7516 y = 0;
7517
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 615 times.
754 else if((int32_t(y)&15) > 7)
7518 139 y=(int32_t(y)&0xF0)+16;
7519 else
7520 615 y=(int32_t(y)&0xF0);
7521
7522 754 break;
7523
7524 case left:
7525 case right:
7526
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1164 times.
1165 if(x < 0)
7527 1 x = 0;
7528
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 825 times.
1164 else if((int32_t(x)&15) > 7)
7529 339 x=(int32_t(x)&0xF0)+16;
7530 else
7531 825 x=(int32_t(x)&0xF0);
7532
7533 1165 break;
7534 }
7535
7536 1922 sclk=0;
7537 1922 clk3=0;
7538 1922 break;
7539 }
7540 }
7541
7542
2/2
✓ Branch 0 taken 34371 times.
✓ Branch 1 taken 2918 times.
37289 if((sclk&255)==0)
7543 {
7544 //hitdir = -1;
7545 2918 sclk=0;
7546 2918 }
7547 37289 return 2;
7548 6855408 }
7549
7550 bool enemy::can_slide()
7551 {
7552 if(sclk==0 || (hp<=0 && !immortal))
7553 return false;
7554
7555 if((sclk&255)==16 && (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
7556 {
7557 return false;
7558 }
7559
7560 return true;
7561 }
7562
7563 bool enemy::fslide()
7564 {
7565 if(sclk==0 || (hp<=0 && !immortal))
7566 return false;
7567
7568 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
7569 {
7570 sclk=0;
7571 return false;
7572 }
7573
7574 --sclk;
7575
7576 switch(sclk>>8)
7577 {
7578 case up:
7579 if(y<=16)
7580 {
7581 sclk=0;
7582 return false;
7583 }
7584
7585 break;
7586
7587 case down:
7588 if(y>=160)
7589 {
7590 sclk=0;
7591 return false;
7592 }
7593
7594 break;
7595
7596 case left:
7597 if(x<=16)
7598 {
7599 sclk=0;
7600 return false;
7601 }
7602
7603 break;
7604
7605 case right:
7606 if(x>=240)
7607 {
7608 sclk=0;
7609 return false;
7610 }
7611
7612 break;
7613 }
7614 hitdir = (sclk>>8);
7615 switch(sclk>>8)
7616 {
7617 case up:
7618 y-=4;
7619 break;
7620
7621 case down:
7622 y+=4;
7623 break;
7624
7625 case left:
7626 x-=4;
7627 break;
7628
7629 case right:
7630 x+=4;
7631 break;
7632 }
7633
7634 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
7635 {
7636 switch(sclk>>8)
7637 {
7638 case up:
7639 case down:
7640 if((int32_t(y)&15) > 7)
7641 y=(int32_t(y)&0xF0)+16;
7642 else
7643 y=(int32_t(y)&0xF0);
7644
7645 break;
7646
7647 case left:
7648 case right:
7649 if((int32_t(x)&15) > 7)
7650 x=(int32_t(x)&0xF0)+16;
7651 else
7652 x=(int32_t(x)&0xF0);
7653
7654 break;
7655 }
7656
7657 sclk=0;
7658 clk3=0;
7659 }
7660
7661 if((sclk&255)==0)
7662 sclk=0;
7663
7664 return true;
7665 }
7666
7667 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
7668 {
7669 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
7670 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
7671 bool ret = sprite::knockback(time, dir, speed);
7672 if(ret) sclk = 0; //kill engine knockback if interrupted
7673 //! Perhaps also set hitdir here, if needed for timing? -Z
7674 return ret;
7675 }
7676
7677 15718848 bool enemy::runKnockback()
7678 {
7679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15718848 times.
15718848 if((script_knockback_clk&0xFF)==0)
7680 {
7681 15718848 script_knockback_clk = 0;
7682 15718848 return false;
7683 }
7684 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
7685 {
7686 return false;
7687 }
7688 int32_t move = script_knockback_speed;
7689 int32_t kb_dir = script_knockback_clk>>8;
7690 --script_knockback_clk;
7691
7692 while(move>0)
7693 {
7694 int32_t thismove = zc_min(get_bit(quest_rules, qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
7695 move -= thismove;
7696 hitdir = kb_dir;
7697 switch(kb_dir)
7698 {
7699 case r_up:
7700 case l_up:
7701 case up:
7702 y-=thismove;
7703 break;
7704
7705 case r_down:
7706 case l_down:
7707 case down:
7708 y+=thismove;
7709 break;
7710 }
7711 switch(kb_dir)
7712 {
7713 case l_up:
7714 case l_down:
7715 case left:
7716 x-=thismove;
7717 break;
7718
7719 case r_up:
7720 case r_down:
7721 case right:
7722 x+=thismove;
7723 break;
7724 }
7725 if (get_bit(quest_rules, qr_OLD_SCRIPTED_KNOCKBACK))
7726 {
7727 if(!canmove(kb_dir,(zfix)0,0,true))
7728 {
7729 script_knockback_clk=0;
7730 clk3=0;
7731 //Fix to grid
7732 switch(kb_dir)
7733 {
7734 case up:
7735 case down:
7736 break;
7737 default:
7738 if(x < 0)
7739 x = 0;
7740 else if((int32_t(x)&15) > 7)
7741 x=(int32_t(x)&0xF0)+16;
7742 else
7743 x=(int32_t(x)&0xF0);
7744 break;
7745 }
7746 switch(kb_dir)
7747 {
7748 case left:
7749 case right:
7750 break;
7751 default:
7752 if(y < 0)
7753 y = 0;
7754 else if((int32_t(y)&15) > 7)
7755 y=(int32_t(y)&0xF0)+16;
7756 else
7757 y=(int32_t(y)&0xF0);
7758 break;
7759 }
7760 break;
7761 }
7762 }
7763 else
7764 {
7765 if(!scr_canplace(x,y,0,true))
7766 {
7767 script_knockback_clk=0;
7768 clk3=0;
7769 //Fix to grid
7770 if (OFFGRID_ENEMY)
7771 {
7772 switch(kb_dir)
7773 {
7774 case up:
7775 case down:
7776 break;
7777 default:
7778 if(x < 0)
7779 x = 0;
7780 else if((int32_t(x)&7) > 3)
7781 x=(int32_t(x)&0xF8)+8;
7782 else
7783 x=(int32_t(x)&0xF8);
7784 break;
7785 }
7786 switch(kb_dir)
7787 {
7788 case left:
7789 case right:
7790 break;
7791 default:
7792 if(y < 0)
7793 y = 0;
7794 else if((int32_t(y)&7) > 3)
7795 y=(int32_t(y)&0xF8)+8;
7796 else
7797 y=(int32_t(y)&0xF8);
7798 break;
7799 }
7800 }
7801 else
7802 {
7803 switch(kb_dir)
7804 {
7805 case up:
7806 case down:
7807 break;
7808 default:
7809 if(x < 0)
7810 x = 0;
7811 else if((int32_t(x)&15) > 7)
7812 x=(int32_t(x)&0xF0)+16;
7813 else
7814 x=(int32_t(x)&0xF0);
7815 break;
7816 }
7817 switch(kb_dir)
7818 {
7819 case left:
7820 case right:
7821 break;
7822 default:
7823 if(y < 0)
7824 y = 0;
7825 else if((int32_t(y)&15) > 7)
7826 y=(int32_t(y)&0xF0)+16;
7827 else
7828 y=(int32_t(y)&0xF0);
7829 break;
7830 }
7831 }
7832 break;
7833 }
7834
7835 }
7836 }
7837 return true;
7838 15718848 }
7839 // changes enemy's direction, checking restrictions
7840 // rate: 0 = no random changes, 16 = always random change
7841 // homing: 0 = none, 256 = always
7842 // grumble 0 = none, 4 = strongest appetite
7843 227955 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
7844 {
7845 227955 int32_t ndir=-1;
7846
7847
4/4
✓ Branch 0 taken 46772 times.
✓ Branch 1 taken 181183 times.
✓ Branch 2 taken 17331 times.
✓ Branch 3 taken 29441 times.
227955 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
7848 {
7849 29441 int32_t i = Lwpns.idFirst(wBait);
7850
1/2
✓ Branch 0 taken 29441 times.
✗ Branch 1 not taken.
29441 if(i >= 0) //idfirst returns -1 if it can't find any
7851 {
7852 weapon *w = (weapon*)Lwpns.spr(i);
7853 if (get_bit(quest_rules, qr_FIND_CLOSEST_BAIT))
7854 {
7855 int32_t currentrange;
7856 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
7857 else currentrange = -1;
7858 int curid = i;
7859 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
7860 for(; i<Lwpns.Count(); ++i)
7861 {
7862 weapon *lw = (weapon*)Lwpns.spr(i);
7863 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
7864 {
7865 currentrange = distance(x, y, lw->x, lw->y);
7866 curid = i;
7867 }
7868 }
7869 i = curid;
7870 if (currentrange == -1) i = -1;
7871 }
7872 else
7873 {
7874 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
7875 }
7876 if (i >= 0)
7877 {
7878 int32_t bx = Lwpns.spr(i)->x;
7879 int32_t by = Lwpns.spr(i)->y;
7880
7881 if(abs(int32_t(y)-by)>14)
7882 {
7883 ndir = (by<y) ? up : down;
7884 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7885 if(canmove(ndir,special,false))
7886 {
7887 dir=ndir;
7888 return;
7889 }
7890 }
7891
7892 ndir = (bx<x) ? left : right;
7893 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7894 if(canmove(ndir,special,false))
7895 {
7896 dir=ndir;
7897 return;
7898 }
7899 }
7900 }
7901 29441 }
7902
7903
2/2
✓ Branch 0 taken 156694 times.
✓ Branch 1 taken 71261 times.
227955 if((zc_oldrand()&255)<abs(newhoming))
7904 {
7905 71261 ndir = lined_up(8,false);
7906
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71261 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
71261 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
7907
4/4
✓ Branch 0 taken 19140 times.
✓ Branch 1 taken 52121 times.
✓ Branch 2 taken 2535 times.
✓ Branch 3 taken 16605 times.
71261 if(ndir>=0 && canmove(ndir,special,false))
7908 {
7909 16605 dir=ndir;
7910 16605 return;
7911 }
7912 54656 }
7913
7914 211350 int32_t i=0;
7915
7916
2/2
✓ Branch 0 taken 974 times.
✓ Branch 1 taken 468220 times.
469194 for(; i<32; i++)
7917 {
7918 468220 int32_t r=zc_oldrand();
7919
7920
2/2
✓ Branch 0 taken 143575 times.
✓ Branch 1 taken 324645 times.
468220 if((r&15)<newrate)
7921 143575 ndir=(r>>4)&3;
7922 else
7923 324645 ndir=dir;
7924
7925
2/2
✓ Branch 0 taken 257844 times.
✓ Branch 1 taken 210376 times.
468220 if(canmove(ndir,special,false))
7926 210376 break;
7927 257844 }
7928
7929
2/2
✓ Branch 0 taken 210376 times.
✓ Branch 1 taken 974 times.
211733 if(i==32)
7930 {
7931
2/2
✓ Branch 0 taken 2872 times.
✓ Branch 1 taken 383 times.
3255 for(ndir=0; ndir<4; ndir++)
7932 {
7933
2/2
✓ Branch 0 taken 2281 times.
✓ Branch 1 taken 591 times.
2872 if(canmove(ndir,special,false))
7934 591 goto ok;
7935 2281 }
7936
7937
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 318 times.
383 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7938 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
7939 383 }
7940
7941 ok:
7942 211350 dir = ndir;
7943 227955 }
7944
7945 769 void enemy::newdir()
7946 {
7947 769 newdir(4,0,spw_none);
7948 769 }
7949
7950 zfix enemy::distance_left()
7951 {
7952 int32_t a2=x.getInt();
7953 int32_t b2=y.getInt();
7954
7955 switch(dir)
7956 {
7957 case up:
7958 return (zfix)(b2&0xF);
7959
7960 case down:
7961 return (zfix)(16-(b2&0xF));
7962
7963 case left:
7964 return (zfix)(a2&0xF);
7965
7966 case right:
7967 return (zfix)(16-(a2&0xF));
7968 }
7969
7970 return (zfix)0;
7971 }
7972
7973 // keeps walking around
7974 162919 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
7975 {
7976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162919 times.
162919 if(slide())
7977 return;
7978
7979
8/12
✓ Branch 0 taken 161055 times.
✓ Branch 1 taken 1864 times.
✓ Branch 2 taken 161055 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159621 times.
✓ Branch 5 taken 1434 times.
✓ Branch 6 taken 159621 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 159621 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 159621 times.
162919 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
7980 3298 return;
7981
7982
2/2
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 149888 times.
159621 if(clk3<=0)
7983 {
7984 9733 fix_coords(true);
7985 9733 newdir(newrate,newhoming,special);
7986
7987
1/2
✓ Branch 0 taken 9733 times.
✗ Branch 1 not taken.
9733 if(step==0)
7988 clk3=0;
7989 else
7990 9733 clk3=int32_t(16.0/step);
7991 9733 }
7992
2/2
✓ Branch 0 taken 149870 times.
✓ Branch 1 taken 18 times.
149888 else if(scored)
7993 {
7994 18 dir^=1;
7995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (step != 0) clk3=int32_t(16.0/step)-clk3;
7996 else clk3=32767;
7997 18 }
7998
7999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159621 times.
159621 if (step != 0) --clk3;
8000 159621 move(step);
8001 162919 }
8002
8003 void enemy::constant_walk()
8004 {
8005 constant_walk(4,0,spw_none);
8006 }
8007
8008 11490 int32_t enemy::pos(int32_t newx,int32_t newy)
8009 {
8010 11490 return (newy<<8)+newx;
8011 }
8012
8013 // for variable step rates
8014 163339 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
8015 {
8016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163339 times.
163339 if(slide())
8017 return;
8018
8019
10/14
✓ Branch 0 taken 163339 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163339 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159369 times.
✓ Branch 5 taken 3970 times.
✓ Branch 6 taken 154093 times.
✓ Branch 7 taken 5276 times.
✓ Branch 8 taken 137258 times.
✓ Branch 9 taken 16835 times.
✓ Branch 10 taken 137258 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 137258 times.
✗ Branch 13 not taken.
163339 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
8020 26081 return;
8021
8022 137258 zfix dx = (zfix)0;
8023 137258 zfix dy = (zfix)0;
8024
8025
4/9
✓ Branch 0 taken 30088 times.
✓ Branch 1 taken 32107 times.
✓ Branch 2 taken 37170 times.
✓ Branch 3 taken 37893 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
137258 switch(dir)
8026 {
8027 case 8:
8028 case up:
8029 30088 dy-=step;
8030 30088 break;
8031
8032 case 12:
8033 case down:
8034 32107 dy+=step;
8035 32107 break;
8036
8037 case 14:
8038 case left:
8039 37170 dx-=step;
8040 37170 break;
8041
8042 case 10:
8043 case right:
8044 37893 dx+=step;
8045 37893 break;
8046
8047 case 15:
8048 case l_up:
8049 dx-=step;
8050 dy-=step;
8051 break;
8052
8053 case 9:
8054 case r_up:
8055 dx+=step;
8056 dy-=step;
8057 break;
8058
8059 case 13:
8060 case l_down:
8061 dx-=step;
8062 dy+=step;
8063 break;
8064
8065 case 11:
8066 case r_down:
8067 dx+=step;
8068 dy+=step;
8069 break;
8070 }
8071
8072
8/8
✓ Branch 0 taken 65961 times.
✓ Branch 1 taken 71297 times.
✓ Branch 2 taken 7132 times.
✓ Branch 3 taken 58829 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3339 times.
✓ Branch 6 taken 132900 times.
✓ Branch 7 taken 4358 times.
137258 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
8073 133465 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
8074 {
8075 4358 fix_coords();
8076 4358 newdir(newrate,newhoming,special);
8077 4358 clk3=pos(x,y);
8078 4358 }
8079
8080 137258 move(step);
8081 163339 }
8082
8083 // pauses for a while after it makes a complete move (to a new square)
8084 5528559 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
8085 {
8086
4/4
✓ Branch 0 taken 32445 times.
✓ Branch 1 taken 5496114 times.
✓ Branch 2 taken 25635 times.
✓ Branch 3 taken 6810 times.
5528559 if(sclk && clk2)
8087 {
8088 6810 clk3=0;
8089 6810 }
8090
8091
11/14
✓ Branch 0 taken 5500754 times.
✓ Branch 1 taken 27805 times.
✓ Branch 2 taken 5500754 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5500754 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5294128 times.
✓ Branch 7 taken 206626 times.
✓ Branch 8 taken 5188263 times.
✓ Branch 9 taken 105865 times.
✓ Branch 10 taken 5186491 times.
✓ Branch 11 taken 1772 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 5186491 times.
5528559 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8092 {
8093 342068 return;
8094 }
8095
8096
2/2
✓ Branch 0 taken 1071058 times.
✓ Branch 1 taken 4115433 times.
5186491 if(clk2>0)
8097 {
8098 1071058 --clk2;
8099 1071058 return;
8100 }
8101
8102
2/2
✓ Branch 0 taken 183299 times.
✓ Branch 1 taken 3932134 times.
4115433 if(clk3<=0)
8103 {
8104 183299 fix_coords(true);
8105 183299 newdir(newrate,newhoming,special);
8106 183299 clk3=int32_t(16.0/step);
8107
2/2
✓ Branch 0 taken 183291 times.
✓ Branch 1 taken 8 times.
183299 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
8108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183299 times.
183299 if(clk2<0)
8109 {
8110 clk2=0;
8111 }
8112
2/2
✓ Branch 0 taken 25252 times.
✓ Branch 1 taken 158047 times.
183299 else if((zc_oldrand()&15)<newhrate)
8113 {
8114 25252 clk2=haltcnt;
8115 25252 return;
8116 }
8117 158047 }
8118
2/2
✓ Branch 0 taken 3931081 times.
✓ Branch 1 taken 1053 times.
3932134 else if(scored)
8119 {
8120 1053 dir^=1;
8121
8122
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1052 times.
1053 if (step != 0) clk3=int32_t(16.0/step)-clk3;
8123 1 else clk3=32767;
8124 1053 }
8125
8126
2/2
✓ Branch 0 taken 11925 times.
✓ Branch 1 taken 4078256 times.
4090181 if (step != 0) --clk3;
8127 4090181 move(step);
8128 5528559 }
8129
8130 // 8-directional movement, aligns to 8 pixels
8131 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
8132 {
8133 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8134 return;
8135
8136 if(clk3<=0)
8137 {
8138 newdir_8(newrate,newhoming,special);
8139 clk3=int32_t(8.0/step);
8140 if (step == 0) clk3 = 32767;
8141 }
8142
8143 if (step != 0) --clk3;
8144 move(step);
8145 }
8146 // 8-directional movement, aligns to 8 pixels
8147 74245 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
8148 {
8149
6/12
✓ Branch 0 taken 74245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74245 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74245 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74245 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 74245 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 74245 times.
74245 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8150 return;
8151
8152
2/2
✓ Branch 0 taken 68773 times.
✓ Branch 1 taken 5472 times.
74245 if(clk3<=0)
8153 {
8154 5472 newdir_8(newrate,newhoming,special);
8155 5472 clk3=int32_t(8.0/step);
8156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if (step == 0) clk3 = 32767;
8157 5472 }
8158
8159
1/2
✓ Branch 0 taken 74245 times.
✗ Branch 1 not taken.
74245 if (step != 0) --clk3;
8160 74245 move(step);
8161 74245 }
8162
8163 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
8164 {
8165 if(clk<0 || dying || stunclk || watch || frozenclock)
8166 return;
8167
8168 if(!canmove(dir,step,special,false))
8169 clk3=0;
8170
8171 if(clk2>0)
8172 {
8173 --clk2;
8174 return;
8175 }
8176
8177 if(clk3<=0)
8178 {
8179 newdir_8(newrate,newhoming,special);
8180 clk3=newclk;
8181
8182 if(clk2<0)
8183 {
8184 clk2=0;
8185 }
8186 else if((zc_oldrand()&15)<newhrate)
8187 {
8188 newdir_8(newrate,newhoming,special);
8189 clk2=haltcnt;
8190 return;
8191 }
8192 }
8193
8194 --clk3;
8195 move(step);
8196 }
8197
8198 // 8-directional movement, no alignment
8199 1919681 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
8200 {
8201
9/12
✓ Branch 0 taken 1844558 times.
✓ Branch 1 taken 75123 times.
✓ Branch 2 taken 1844558 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1826436 times.
✓ Branch 5 taken 18122 times.
✓ Branch 6 taken 1819894 times.
✓ Branch 7 taken 6542 times.
✓ Branch 8 taken 1819894 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1819894 times.
1919681 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8202 99787 return;
8203
8204
2/2
✓ Branch 0 taken 1806758 times.
✓ Branch 1 taken 13136 times.
1819894 if(!canmove(dir,step,special,false))
8205 13136 clk3=0;
8206
8207
2/2
✓ Branch 0 taken 1589711 times.
✓ Branch 1 taken 230183 times.
1819894 if(clk3<=0)
8208 {
8209 230183 newdir_8(newrate,newhoming,special);
8210 230183 clk3=newclk;
8211 230183 }
8212
8213 1819894 --clk3;
8214 1819894 move(step);
8215 1919681 }
8216
8217 // same as above but with variable enemy size
8218 42942 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
8219 {
8220
8/12
✓ Branch 0 taken 42394 times.
✓ Branch 1 taken 548 times.
✓ Branch 2 taken 42394 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42394 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42343 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 42343 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 42343 times.
42942 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8221 599 return;
8222
8223
2/2
✓ Branch 0 taken 41867 times.
✓ Branch 1 taken 476 times.
42343 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
8224 476 clk3=0;
8225
8226
2/2
✓ Branch 0 taken 39475 times.
✓ Branch 1 taken 2868 times.
42343 if(clk3<=0)
8227 {
8228 2868 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
8229 2868 clk3=newclk;
8230 2868 }
8231
8232 42343 --clk3;
8233 42343 move(step);
8234 42942 }
8235
8236 // the variable speed floater movement
8237 // ms is max speed
8238 // ss is step speed
8239 // s is step count
8240 // p is pause count
8241 // g is graduality :)
8242 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
8243 1588819 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8244 {
8245 1588819 ++clk2;
8246 1588819 byte over_pit = overpit(this);
8247
8248
4/4
✓ Branch 0 taken 408682 times.
✓ Branch 1 taken 1180137 times.
✓ Branch 2 taken 408415 times.
✓ Branch 3 taken 267 times.
1588819 if(dmisc1 && over_pit) p = 0;
8249
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 30408 times.
✓ Branch 2 taken 573151 times.
✓ Branch 3 taken 919072 times.
✓ Branch 4 taken 66188 times.
1588819 switch(movestatus)
8250 {
8251 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
8252 //! if the conditions prevent it, we jump back to case 2.
8253 case 0: // paused
8254
2/2
✓ Branch 0 taken 29779 times.
✓ Branch 1 taken 629 times.
30408 if(clk2>=p)
8255 {
8256 629 movestatus=1;
8257 629 clk2=0;
8258 629 }
8259
8260 30408 break;
8261
8262 case 1: // speeding up
8263
1/2
✓ Branch 0 taken 573151 times.
✗ Branch 1 not taken.
573151 if (s >= 0)
8264 {
8265
2/2
✓ Branch 0 taken 568955 times.
✓ Branch 1 taken 4196 times.
573151 if(clk2<g*s)
8266 {
8267
2/2
✓ Branch 0 taken 532547 times.
✓ Branch 1 taken 36408 times.
568955 if(!((clk2-1)%g))
8268 36408 step+=ss;
8269 568955 }
8270 else
8271 {
8272 4196 movestatus=2;
8273 4196 clk2=0;
8274 }
8275 573151 }
8276 else
8277 {
8278 if(step < ms)
8279 {
8280 if(!((clk2-1)%g))
8281 {
8282 step+=ss;
8283 if (step >= ms) step = ms;
8284 }
8285 }
8286 else
8287 {
8288 step = ms;
8289 movestatus=2;
8290 clk2=0;
8291 }
8292 }
8293
8294 573151 break;
8295
8296 case 2: // normal
8297 919072 step=ms;
8298
8299
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 919072 times.
✓ Branch 2 taken 181371 times.
✓ Branch 3 taken 737701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 737701 times.
✓ Branch 6 taken 736716 times.
✓ Branch 7 taken 985 times.
919072 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
8300 {
8301
1/2
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
985 if (s >= 0) step=ss*s;
8302 else step=ms;
8303 985 movestatus=3;
8304 985 clk2=0;
8305 985 }
8306
8307 919072 break;
8308
8309 case 3: // slowing down
8310
1/2
✓ Branch 0 taken 66188 times.
✗ Branch 1 not taken.
66188 if (s >= 0)
8311 {
8312
2/2
✓ Branch 0 taken 65463 times.
✓ Branch 1 taken 725 times.
66188 if(clk2<=g*s)
8313 {
8314 { //don't slow down over pits
8315
8316
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 65451 times.
65463 if(over_pit)
8317 {
8318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(dmisc1)
8319 {
8320 step=ms;
8321 }
8322 12 }
8323 else //can slow down
8324 {
8325
4/4
✓ Branch 0 taken 4078 times.
✓ Branch 1 taken 61373 times.
✓ Branch 2 taken 3816 times.
✓ Branch 3 taken 262 times.
65451 if(!(clk2%g) && !dmisc1)
8326 3816 step-=ss;
8327 }
8328 }
8329
8330
8331 65463 }
8332 else
8333 {
8334 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
8335 //this doesn't help keese, as they have a z of 0.
8336 //they always nee to run this check.
8337 {
8338
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 725 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
725 if(over_pit &&!dmisc1)
8339 {
8340 --clk2; //if over a pit, don't land, and revert clock change
8341 }
8342 else //can land safely
8343 {
8344 725 movestatus=0;
8345
3/4
✓ Branch 0 taken 445 times.
✓ Branch 1 taken 280 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 445 times.
725 if(dmisc1&&!over_pit)
8346 445 step=0;
8347 725 clk2=0;
8348 }
8349 }
8350
8351 }
8352 66188 }
8353 else
8354 {
8355 if(step > 0)
8356 {
8357 if(over_pit)
8358 {
8359 if(dmisc1)
8360 {
8361 step=ms;
8362 }
8363 }
8364 else //can slow down
8365 {
8366 if(!(clk2%g))
8367 step-=ss;
8368 }
8369 }
8370 else
8371 {
8372 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
8373 //this doesn't help keese, as they have a z of 0.
8374 //they always nee to run this check.
8375 if(over_pit)
8376 {
8377 step+=ss; //if over a pit, don't land, and revert clock change
8378 }
8379 else //can land safely
8380 {
8381 movestatus=0;
8382 step=0;
8383 clk2=0;
8384 }
8385 }
8386 }
8387
8388 66188 break;
8389 }
8390
8391
2/2
✓ Branch 0 taken 922283 times.
✓ Branch 1 taken 666536 times.
1588819 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
8392 1588819 }
8393
8394 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
8395 {
8396 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
8397 }
8398
8399 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
8400 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
8401 383477 int32_t enemy::lined_up(int32_t range, bool dir8)
8402 {
8403 383477 int32_t lx = Hero.getX();
8404 383477 int32_t ly = Hero.getY();
8405
8406
2/2
✓ Branch 0 taken 14949 times.
✓ Branch 1 taken 368528 times.
383477 if(abs(lx-int32_t(x))<=range)
8407 {
8408
2/2
✓ Branch 0 taken 5775 times.
✓ Branch 1 taken 9174 times.
14949 if(ly<y)
8409 {
8410 5775 return up;
8411 }
8412
8413 9174 return down;
8414 }
8415
8416
2/2
✓ Branch 0 taken 17649 times.
✓ Branch 1 taken 350879 times.
368528 if(abs(ly-int32_t(y))<=range)
8417 {
8418
2/2
✓ Branch 0 taken 8750 times.
✓ Branch 1 taken 8899 times.
17649 if(lx<x)
8419 {
8420 8750 return left;
8421 }
8422
8423 8899 return right;
8424 }
8425
8426
2/2
✓ Branch 0 taken 69109 times.
✓ Branch 1 taken 281770 times.
350879 if(dir8)
8427 {
8428
2/2
✓ Branch 0 taken 96658 times.
✓ Branch 1 taken 185112 times.
281770 if(abs(lx-x)-abs(ly-y)<=range)
8429 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
8430 {
8431
2/2
✓ Branch 0 taken 42725 times.
✓ Branch 1 taken 53933 times.
96658 if(ly<y)
8432 {
8433
2/2
✓ Branch 0 taken 24747 times.
✓ Branch 1 taken 17978 times.
42725 if(lx<x)
8434 {
8435 24747 return l_up;
8436 }
8437 else
8438 {
8439 17978 return r_up;
8440 }
8441 }
8442 else
8443 {
8444
2/2
✓ Branch 0 taken 27282 times.
✓ Branch 1 taken 26651 times.
53933 if(lx<x)
8445 {
8446 26651 return l_down;
8447 }
8448 else
8449 {
8450 27282 return r_down;
8451 }
8452 }
8453 }
8454 185112 }
8455
8456 254221 return -1;
8457 383477 }
8458
8459 // returns true if Hero is within 'range' pixels of the enemy
8460 12998 bool enemy::HeroInRange(int32_t range)
8461 {
8462 12998 int32_t lx = Hero.getX();
8463 12998 int32_t ly = Hero.getY();
8464
2/2
✓ Branch 0 taken 10857 times.
✓ Branch 1 taken 2141 times.
12998 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
8465 }
8466
8467 // place the enemy in line with Hero (red wizzrobes)
8468 1871 void enemy::place_on_axis(bool floater, bool solid_ok)
8469 {
8470
6/6
✓ Branch 0 taken 1543 times.
✓ Branch 1 taken 328 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 171 times.
✓ Branch 4 taken 1372 times.
✓ Branch 5 taken 328 times.
1871 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
8471
6/6
✓ Branch 0 taken 1557 times.
✓ Branch 1 taken 314 times.
✓ Branch 2 taken 1612 times.
✓ Branch 3 taken 259 times.
✓ Branch 4 taken 1298 times.
✓ Branch 5 taken 314 times.
1871 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
8472 1871 int32_t pos2=zc_oldrand()%23;
8473 1871 int32_t tried=0;
8474 1871 bool last_resort,placed=false;
8475
8476
8477 1871 do
8478 {
8479
2/2
✓ Branch 0 taken 1845 times.
✓ Branch 1 taken 1317 times.
3162 if(pos2<14)
8480 {
8481 1845 x=(pos2<<4)+16;
8482 1845 y=ly;
8483 1845 }
8484 else
8485 {
8486 1317 x=lx;
8487 1317 y=((pos2-14)<<4)+16;
8488 }
8489
8490 // Don't commit to a last resort if position is out of bounds.
8491
6/6
✓ Branch 0 taken 3040 times.
✓ Branch 1 taken 122 times.
✓ Branch 2 taken 2914 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 2820 times.
3162 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
8492
8493
4/4
✓ Branch 0 taken 1637 times.
✓ Branch 1 taken 1525 times.
✓ Branch 2 taken 2777 times.
✓ Branch 3 taken 1658 times.
3162 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
8494 {
8495 // Red Wizzrobes should be able to appear on water, but not other
8496 // solid combos; however, they could appear on solid combos in 2.10,
8497 // and some quests depend on that.
8498
4/4
✓ Branch 0 taken 1456 times.
✓ Branch 1 taken 2846 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1871 times.
4302 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
8499 4302 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
8500 1871 placed=true;
8501 4302 }
8502
8503
3/6
✓ Branch 0 taken 1291 times.
✓ Branch 1 taken 2855 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1291 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4146 if(!placed && tried>=22 && last_resort)
8504 {
8505 placed=true;
8506 }
8507
8508 4146 ++tried;
8509 4146 pos2=(pos2+3)%23;
8510
2/2
✓ Branch 0 taken 1291 times.
✓ Branch 1 taken 2855 times.
4146 }
8511 4146 while(!placed);
8512
8513
2/2
✓ Branch 0 taken 2157 times.
✓ Branch 1 taken 698 times.
2855 if(y==ly)
8514 2157 dir=(x<lx)?right:left;
8515 else
8516 698 dir=(y<ly)?down:up;
8517
8518 2855 clk2=tried;
8519 2855 }
8520
8521 8749721 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
8522 {
8523 8749721 int32_t t = o_tile;
8524 8749721 int32_t b = o_tile;
8525
8526 // Darknuts, but also Wizzrobes and Wallmasters
8527
3/4
✓ Branch 0 taken 3189553 times.
✓ Branch 1 taken 5241526 times.
✓ Branch 2 taken 318642 times.
✗ Branch 3 not taken.
8749721 switch(family)
8528 {
8529 case eeWALK:
8530
5/6
✓ Branch 0 taken 369324 times.
✓ Branch 1 taken 4872202 times.
✓ Branch 2 taken 261311 times.
✓ Branch 3 taken 108013 times.
✓ Branch 4 taken 261311 times.
✗ Branch 5 not taken.
5241526 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
8531 {
8532 261311 tile=s_tile;
8533 261311 t=s_tile;
8534 261311 b=s_tile;
8535 261311 }
8536
8537 5241526 break;
8538
8539 case eeTRAP:
8540
4/6
✓ Branch 0 taken 121158 times.
✓ Branch 1 taken 197484 times.
✓ Branch 2 taken 121158 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 121158 times.
318642 if(dummy_int[1] && guysbuf[id].flags2 & eneflag_trp2 && do_animation) // Just to make sure
8541 {
8542 121158 tile=s_tile;
8543 121158 t=s_tile;
8544 121158 b=s_tile;
8545 121158 }
8546
8547 318642 break;
8548
8549 case eeSPINTILE:
8550 if(misc>=96 && do_animation)
8551 {
8552 tile=o_tile+frames*ndir;
8553 t=tile;
8554 }
8555
8556 break;
8557 }
8558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8749721 times.
8749721 if ( do_animation )
8559 {
8560
4/6
✓ Branch 0 taken 105723 times.
✓ Branch 1 taken 8643998 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77420 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8566578 times.
8749721 if(ndir!=0) switch(frames)
8561 {
8562 case 2:
8563 77420 tiledir_small(dir,ndir==4);
8564 77420 break;
8565
8566 case 3:
8567 tiledir_three(dir);
8568 break;
8569
8570 case 4:
8571 8566578 tiledir(dir,ndir==4);
8572 8566578 break;
8573 8643998 }
8574
8575
2/2
✓ Branch 0 taken 5241526 times.
✓ Branch 1 taken 3508195 times.
8749721 if(family==eeWALK)
8576
6/6
✓ Branch 0 taken 4175448 times.
✓ Branch 1 taken 1066078 times.
✓ Branch 2 taken 3924446 times.
✓ Branch 3 taken 1317080 times.
✓ Branch 4 taken 1042502 times.
✓ Branch 5 taken 274578 times.
5241526 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
8577 else
8578 3508195 tile+=f4;
8579 8749721 }
8580 8749721 return b;
8581 }
8582
8583 void enemy::tiledir_three(int32_t ndir)
8584 {
8585 if ( !do_animation ) return;
8586 flip=0;
8587
8588 switch(ndir)
8589 {
8590 case right:
8591 tile+=3;
8592 [[fallthrough]];
8593
8594 case left:
8595 tile+=3;
8596 [[fallthrough]];
8597
8598 case down:
8599 tile+=3;
8600 [[fallthrough]];
8601
8602 case up:
8603 break;
8604 }
8605 }
8606
8607 77420 void enemy::tiledir_small(int32_t ndir, bool fourdir)
8608 {
8609
1/2
✓ Branch 0 taken 77420 times.
✗ Branch 1 not taken.
77420 if ( !do_animation ) return;
8610 77420 flip=0;
8611
8612
4/9
✓ Branch 0 taken 17011 times.
✓ Branch 1 taken 16756 times.
✓ Branch 2 taken 22057 times.
✓ Branch 3 taken 21596 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
77420 switch(ndir)
8613 {
8614 case 8:
8615 case up:
8616 17011 break;
8617
8618 case 12:
8619 case down:
8620 16756 tile+=2;
8621 16756 break;
8622
8623 case 14:
8624 case left:
8625 22057 tile+=4;
8626 22057 break;
8627
8628 case 10:
8629 case right:
8630 21596 tile+=6;
8631 21596 break;
8632
8633 case 9:
8634 case r_up:
8635 if(fourdir)
8636 break;
8637
8638 tile+=10;
8639 break;
8640
8641 case 11:
8642 case r_down:
8643 if(fourdir)
8644 tile+=2;
8645 else
8646 tile+=14;
8647
8648 break;
8649
8650 case 13:
8651 case l_down:
8652 if(fourdir)
8653 tile+=2;
8654 else
8655 tile+=12;
8656
8657 break;
8658
8659 case 15:
8660 case l_up:
8661 if(fourdir)
8662 break;
8663
8664 tile+=8;
8665 break;
8666
8667 default:
8668 //dir=(zc_oldrand()*100)%8;
8669 //tiledir_small(dir);
8670 // flip=zc_oldrand()&3;
8671 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8672 break;
8673 }
8674 77420 }
8675
8676 10046684 void enemy::tiledir(int32_t ndir, bool fourdir)
8677 {
8678
1/2
✓ Branch 0 taken 10046684 times.
✗ Branch 1 not taken.
10046684 if ( !do_animation ) return;
8679 10046684 flip=0;
8680
8681
9/9
✓ Branch 0 taken 2011690 times.
✓ Branch 1 taken 1735796 times.
✓ Branch 2 taken 2400406 times.
✓ Branch 3 taken 2310034 times.
✓ Branch 4 taken 357701 times.
✓ Branch 5 taken 435144 times.
✓ Branch 6 taken 420302 times.
✓ Branch 7 taken 369004 times.
✓ Branch 8 taken 6607 times.
10046684 switch(ndir)
8682 {
8683 case 8:
8684 case up:
8685 2011690 break;
8686
8687 case 12:
8688 case down:
8689 1735796 tile+=4;
8690 1735796 break;
8691
8692 case 14:
8693 case left:
8694 2400406 tile+=8;
8695 2400406 break;
8696
8697 case 10:
8698 case right:
8699 2310034 tile+=12;
8700 2310034 break;
8701
8702 case 9:
8703 case r_up:
8704
2/2
✓ Branch 0 taken 53601 times.
✓ Branch 1 taken 304100 times.
357701 if(fourdir)
8705 53601 break;
8706 else
8707 304100 tile+=24;
8708
8709 304100 break;
8710
8711 case 11:
8712 case r_down:
8713
2/2
✓ Branch 0 taken 58633 times.
✓ Branch 1 taken 376511 times.
435144 if(fourdir)
8714 58633 tile+=4;
8715 else
8716 376511 tile+=32;
8717
8718 435144 break;
8719
8720 case 13:
8721 case l_down:
8722
2/2
✓ Branch 0 taken 61333 times.
✓ Branch 1 taken 358969 times.
420302 if(fourdir)
8723 61333 tile+=4;
8724 else
8725 358969 tile+=28;
8726
8727 420302 break;
8728
8729 case 15:
8730 case l_up:
8731
2/2
✓ Branch 0 taken 46455 times.
✓ Branch 1 taken 322549 times.
369004 if(fourdir)
8732 46455 break;
8733 else
8734 322549 tile+=20;
8735
8736 322549 break;
8737
8738 default:
8739 //dir=(zc_oldrand()*100)%8;
8740 //tiledir(dir);
8741 // flip=zc_oldrand()&3;
8742 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8743 6607 break;
8744 }
8745 10046684 }
8746
8747 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
8748 {
8749
1/2
✓ Branch 0 taken 3868 times.
✗ Branch 1 not taken.
3868 if ( !do_animation ) return;
8750 3868 flip=0;
8751
8752
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
8753 {
8754 case 8:
8755 case up:
8756 297 break;
8757
8758 case 12:
8759 case down:
8760 tile+=8;
8761 break;
8762
8763 case 14:
8764 case left:
8765 195 tile+=40;
8766 195 break;
8767
8768 case 10:
8769 case right:
8770 179 tile+=48;
8771 179 break;
8772
8773 case 9:
8774 case r_up:
8775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
8776 break;
8777
8778 306 tile+=88;
8779 306 break;
8780
8781 case 11:
8782 case r_down:
8783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
8784 tile+=8;
8785 else
8786 1235 tile+=128;
8787
8788 1235 break;
8789
8790 case 13:
8791 case l_down:
8792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
8793 tile+=8;
8794 else
8795 1324 tile+=120;
8796
8797 1324 break;
8798
8799 case 15:
8800 case l_up:
8801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
8802 break;
8803
8804 332 tile+=80;
8805 332 break;
8806
8807 default:
8808 //dir=(zc_oldrand()*100)%8;
8809 //tiledir_big(dir);
8810 // flip=zc_oldrand()&3;
8811 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8812 break;
8813 }
8814 3868 }
8815
8816 17237734 void enemy::update_enemy_frame()
8817 {
8818
3/4
✓ Branch 0 taken 17237592 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17237592 times.
17237734 if(fallclk||drownclk) return;
8819
1/2
✓ Branch 0 taken 17237592 times.
✗ Branch 1 not taken.
17237592 if (!do_animation)
8820 return;
8821
8822
3/4
✓ Branch 0 taken 215596 times.
✓ Branch 1 taken 17021996 times.
✓ Branch 2 taken 215596 times.
✗ Branch 3 not taken.
17237592 if (get_bit(quest_rules,qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
8823
8824
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
17237592 if(get_bit(quest_rules,qr_ANONE_NOANIM)
8825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17237592 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17237592 && anim == aNONE && family != eeGUY)
8826 return;
8827
2/2
✓ Branch 0 taken 16960939 times.
✓ Branch 1 taken 276653 times.
17237592 int32_t newfrate = zc_max(frate,4);
8828 17237592 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
8829 17237592 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
8830
2/2
✓ Branch 0 taken 13040976 times.
✓ Branch 1 taken 4196616 times.
17237592 int32_t fx = get_bit(quest_rules, qr_NEWENEMYTILES) ? f4 : f2;
8831 17237592 tile = o_tile;
8832 17237592 int32_t basetile = o_tile;
8833 17237592 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
8834 17237592 bool ignore_extend = false;
8835
34/40
✓ Branch 0 taken 67625 times.
✓ Branch 1 taken 2553 times.
✓ Branch 2 taken 35552 times.
✓ Branch 3 taken 829242 times.
✓ Branch 4 taken 216057 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46675 times.
✓ Branch 7 taken 202996 times.
✓ Branch 8 taken 125758 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2100562 times.
✓ Branch 12 taken 28657 times.
✓ Branch 13 taken 48420 times.
✓ Branch 14 taken 818 times.
✓ Branch 15 taken 199178 times.
✓ Branch 16 taken 595734 times.
✓ Branch 17 taken 105723 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 48711 times.
✓ Branch 20 taken 114069 times.
✓ Branch 21 taken 400124 times.
✓ Branch 22 taken 626088 times.
✓ Branch 23 taken 596152 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 77420 times.
✓ Branch 26 taken 1882394 times.
✓ Branch 27 taken 3306355 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 160855 times.
✓ Branch 30 taken 319741 times.
✓ Branch 31 taken 442753 times.
✓ Branch 32 taken 45658 times.
✓ Branch 33 taken 1192542 times.
✓ Branch 34 taken 21820 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 3036014 times.
✓ Branch 37 taken 281252 times.
✓ Branch 38 taken 39993 times.
✓ Branch 39 taken 36233 times.
17237592 switch(anim)
8836 {
8837
8838 case aDONGO:
8839 {
8840 28657 int32_t fr = stunclk>0 ? 16 : 8;
8841
8842
6/6
✓ Branch 0 taken 27559 times.
✓ Branch 1 taken 1098 times.
✓ Branch 2 taken 3456 times.
✓ Branch 3 taken 24103 times.
✓ Branch 4 taken 1152 times.
✓ Branch 5 taken 2304 times.
28657 if(!dying && clk2>0 && clk2<=64)
8843 {
8844 // bloated
8845
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 512 times.
2304 switch(dir)
8846 {
8847 case up:
8848 512 tile+=9;
8849 512 flip=0;
8850 512 xofs=0;
8851 512 dummy_int[1]=0; //no additional tiles
8852 512 break;
8853
8854 case down:
8855 256 tile+=7;
8856 256 flip=0;
8857 256 xofs=0;
8858 256 dummy_int[1]=0; //no additional tiles
8859 256 break;
8860
8861 case left:
8862 1024 flip=1;
8863 1024 tile+=4;
8864 1024 xofs=16;
8865 1024 dummy_int[1]=1; //second tile is next tile
8866 1024 break;
8867
8868 case right:
8869 512 flip=0;
8870 512 tile+=5;
8871 512 xofs=16;
8872 512 dummy_int[1]=-1; //second tile is previous tile
8873 512 break;
8874 }
8875 2304 }
8876
4/4
✓ Branch 0 taken 1098 times.
✓ Branch 1 taken 25255 times.
✓ Branch 2 taken 568 times.
✓ Branch 3 taken 530 times.
26353 else if(!dying || clk2>19)
8877 {
8878 // normal
8879
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5442 times.
✓ Branch 2 taken 5800 times.
✓ Branch 3 taken 8935 times.
✓ Branch 4 taken 5646 times.
25823 switch(dir)
8880 {
8881 case up:
8882 5442 tile+=8;
8883 5442 flip=(clk&fr)?1:0;
8884 5442 xofs=0;
8885 5442 dummy_int[1]=0; //no additional tiles
8886 5442 break;
8887
8888 case down:
8889 5800 tile+=6;
8890 5800 flip=(clk&fr)?1:0;
8891 5800 xofs=0;
8892 5800 dummy_int[1]=0; //no additional tiles
8893 5800 break;
8894
8895 case left:
8896 8935 flip=1;
8897 8935 tile+=(clk&fr)?2:0;
8898 8935 xofs=16;
8899 8935 dummy_int[1]=1; //second tile is next tile
8900 8935 break;
8901
8902 case right:
8903 5646 flip=0;
8904 5646 tile+=(clk&fr)?3:1;
8905 5646 xofs=16;
8906 5646 dummy_int[1]=-1; //second tile is next tile
8907 5646 break;
8908 }
8909 25823 }
8910 }
8911 28657 break;
8912
8913 case aNEWDONGO:
8914 {
8915 48420 int32_t fr4=0;
8916
8917
6/6
✓ Branch 0 taken 46728 times.
✓ Branch 1 taken 1692 times.
✓ Branch 2 taken 3648 times.
✓ Branch 3 taken 43080 times.
✓ Branch 4 taken 1216 times.
✓ Branch 5 taken 2432 times.
48420 if(!dying && clk2>0 && clk2<=64)
8918 {
8919 // bloated
8920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2432 times.
2432 if(clk2>=0)
8921 {
8922 2432 fr4=3;
8923 2432 }
8924
8925
2/2
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 1862 times.
2432 if(clk2>=16)
8926 {
8927 1862 fr4=2;
8928 1862 }
8929
8930
2/2
✓ Branch 0 taken 1178 times.
✓ Branch 1 taken 1254 times.
2432 if(clk2>=32)
8931 {
8932 1254 fr4=1;
8933 1254 }
8934
8935
2/2
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 646 times.
2432 if(clk2>=48)
8936 {
8937 646 fr4=0;
8938 646 }
8939
8940
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1024 times.
2432 switch(dir)
8941 {
8942 case up:
8943 256 xofs=0;
8944 256 tile+=8+fr4;
8945 256 dummy_int[1]=0; //no additional tiles
8946 256 break;
8947
8948 case down:
8949 576 xofs=0;
8950 576 tile+=12+fr4;
8951 576 dummy_int[1]=0; //no additional tiles
8952 576 break;
8953
8954 case left:
8955 576 tile+=29+(2*fr4);
8956 576 xofs=16;
8957 576 dummy_int[1]=-1; //second tile is previous tile
8958 576 break;
8959
8960 case right:
8961 1024 tile+=49+(2*fr4);
8962 1024 xofs=16;
8963 1024 dummy_int[1]=-1; //second tile is previous tile
8964 1024 break;
8965 }
8966 2432 }
8967
4/4
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 44296 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 769 times.
45988 else if(!dying || clk2>19)
8968 {
8969 // normal
8970
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8569 times.
✓ Branch 2 taken 8925 times.
✓ Branch 3 taken 13235 times.
✓ Branch 4 taken 14490 times.
45219 switch(dir)
8971 {
8972 case up:
8973 8569 xofs=0;
8974 8569 tile+=((clk&12)>>2);
8975 8569 dummy_int[1]=0; //no additional tiles
8976 8569 break;
8977
8978 case down:
8979 8925 xofs=0;
8980 8925 tile+=4+((clk&12)>>2);
8981 8925 dummy_int[1]=0; //no additional tiles
8982 8925 break;
8983
8984 case left:
8985 13235 tile+=21+((clk&12)>>1);
8986 13235 xofs=16;
8987 13235 dummy_int[1]=-1; //second tile is previous tile
8988 13235 break;
8989
8990 case right:
8991 14490 flip=0;
8992 14490 tile+=41+((clk&12)>>1);
8993 14490 xofs=16;
8994 14490 dummy_int[1]=-1; //second tile is previous tile
8995 14490 break;
8996 }
8997 45219 }
8998 }
8999 48420 break;
9000
9001 case aDONGOBS:
9002 {
9003 818 int32_t fr4=0;
9004
9005
6/6
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 590 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 128 times.
818 if(!dying && clk2>0 && clk2<=64)
9006 {
9007 // bloated
9008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(clk2>=0)
9009 {
9010 128 fr4=3;
9011 128 }
9012
9013
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(clk2>=16)
9014 {
9015 98 fr4=2;
9016 98 }
9017
9018
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 66 times.
128 if(clk2>=32)
9019 {
9020 66 fr4=1;
9021 66 }
9022
9023
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 34 times.
128 if(clk2>=48)
9024 {
9025 34 fr4=0;
9026 34 }
9027
9028
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
128 switch(dir)
9029 {
9030 case up:
9031 tile+=28+fr4;
9032 yofs+=8;
9033 dummy_int[1]=-20; //second tile change
9034 dummy_int[2]=0; //new xofs change
9035 dummy_int[3]=-16; //new xofs change
9036 break;
9037
9038 case down:
9039 tile+=12+fr4;
9040 yofs-=8;
9041 dummy_int[1]=20; //second tile change
9042 dummy_int[2]=0; //new xofs change
9043 dummy_int[3]=16; //new xofs change
9044 break;
9045
9046 case left:
9047 128 tile+=49+(2*fr4);
9048 128 xofs+=8;
9049 128 dummy_int[1]=-1; //second tile change
9050 128 dummy_int[2]=-16; //new xofs change
9051 128 dummy_int[3]=0; //new xofs change
9052 128 break;
9053
9054 case right:
9055 tile+=69+(2*fr4);
9056 xofs+=8;
9057 dummy_int[1]=-1; //second tile change
9058 dummy_int[2]=-16; //new xofs change
9059 dummy_int[3]=0; //new xofs change
9060 break;
9061 }
9062 128 }
9063
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
690 else if(!dying || clk2>19)
9064 {
9065 // normal
9066
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 332 times.
✓ Branch 4 taken 97 times.
654 switch(dir)
9067 {
9068 case up:
9069 96 tile+=20+((clk&24)>>3);
9070 96 yofs+=8;
9071 96 dummy_int[1]=-20; //second tile change
9072 96 dummy_int[2]=0; //new xofs change
9073 96 dummy_int[3]=-16; //new xofs change
9074 96 break;
9075
9076 case down:
9077 129 tile+=4+((clk&24)>>3);
9078 129 yofs-=8;
9079 129 dummy_int[1]=20; //second tile change
9080 129 dummy_int[2]=0; //new xofs change
9081 129 dummy_int[3]=16; //new xofs change
9082 129 break;
9083
9084 case left:
9085 332 xofs=-8;
9086 332 tile+=40+((clk&24)>>2);
9087 332 dummy_int[1]=1; //second tile change
9088 332 dummy_int[2]=16; //new xofs change
9089 332 dummy_int[3]=0; //new xofs change
9090 332 break;
9091
9092 case right:
9093 97 tile+=60+((clk&24)>>2);
9094 97 xofs=-8;
9095 97 dummy_int[1]=1; //second tile change
9096 97 dummy_int[2]=16; //new xofs change
9097 97 dummy_int[3]=0; //new xofs change
9098 97 break;
9099 }
9100 654 }
9101 }
9102 818 break;
9103
9104 case aWIZZ:
9105 {
9106 // if(d->misc1)
9107
2/2
✓ Branch 0 taken 55336 times.
✓ Branch 1 taken 143842 times.
199178 if(dmisc1)
9108 {
9109
2/2
✓ Branch 0 taken 27886 times.
✓ Branch 1 taken 27450 times.
55336 if(clk&8)
9110 {
9111 27450 ++tile;
9112 27450 }
9113 55336 }
9114 else
9115 {
9116
2/2
✓ Branch 0 taken 71986 times.
✓ Branch 1 taken 71856 times.
143842 if(frame&4)
9117 {
9118 71856 ++tile;
9119 71856 }
9120 }
9121
9122
4/4
✓ Branch 0 taken 33876 times.
✓ Branch 1 taken 62571 times.
✓ Branch 2 taken 67454 times.
✓ Branch 3 taken 35277 times.
199178 switch(dir)
9123 {
9124 case 9:
9125 case 15:
9126 case up:
9127 33876 tile+=2;
9128 33876 break;
9129
9130 case down:
9131 35277 break;
9132
9133 case 13:
9134 case left:
9135 62571 flip=1;
9136 62571 break;
9137
9138 default:
9139 67454 flip=0;
9140 67454 break;
9141 }
9142 }
9143 199178 break;
9144
9145 case aNEWWIZZ:
9146 {
9147 595734 tiledir(dir,true);
9148
9149 // if(d->misc1) //walking wizzrobe
9150
2/2
✓ Branch 0 taken 316790 times.
✓ Branch 1 taken 278944 times.
595734 if(dmisc1) //walking wizzrobe
9151 {
9152
2/2
✓ Branch 0 taken 159200 times.
✓ Branch 1 taken 157590 times.
316790 if(clk&8)
9153 {
9154 157590 tile+=2;
9155 157590 }
9156
9157
2/2
✓ Branch 0 taken 158616 times.
✓ Branch 1 taken 158174 times.
316790 if(clk&4)
9158 {
9159 158174 tile+=1;
9160 158174 }
9161
9162
2/4
✓ Branch 0 taken 316790 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 316790 times.
316790 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
9163 {
9164
2/2
✓ Branch 0 taken 283104 times.
✓ Branch 1 taken 33686 times.
316790 if(dummy_int[1]>0)
9165 {
9166 33686 tile+=40;
9167 33686 }
9168 316790 }
9169 316790 }
9170 else
9171 {
9172
4/4
✓ Branch 0 taken 255725 times.
✓ Branch 1 taken 23219 times.
✓ Branch 2 taken 59829 times.
✓ Branch 3 taken 195896 times.
278944 if(dummy_bool[1]||dummy_bool[2])
9173 {
9174 83048 tile+=20;
9175
9176
2/2
✓ Branch 0 taken 23219 times.
✓ Branch 1 taken 59829 times.
83048 if(dummy_bool[2])
9177 {
9178 59829 tile+=20;
9179 59829 }
9180 83048 }
9181
9182 278944 tile+=((frame>>1)&3);
9183 }
9184 }
9185 595734 break;
9186
9187 case a3FRM:
9188 {
9189
2/2
✓ Branch 0 taken 25554 times.
✓ Branch 1 taken 80169 times.
105723 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
9190 }
9191 105723 break;
9192
9193 case a3FRM4DIR:
9194 {
9195 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
9196 }
9197 break;
9198
9199 case aVIRE:
9200 {
9201
2/2
✓ Branch 0 taken 37532 times.
✓ Branch 1 taken 11179 times.
48711 if(dir==up)
9202 {
9203 11179 tile+=2;
9204 11179 }
9205
9206 48711 tile+=fx;
9207 }
9208 48711 break;
9209
9210 case aROPE:
9211 {
9212 67625 tile+=(1-fx);
9213 67625 flip = dir==left ? 1:0;
9214 }
9215 67625 break;
9216
9217 case aZORA:
9218 {
9219 int32_t dl;
9220
9221
2/2
✓ Branch 0 taken 23518 times.
✓ Branch 1 taken 90551 times.
114069 if(clk<36)
9222 {
9223 23518 dl=clk+5;
9224 23518 goto waves2;
9225 }
9226
9227
2/2
✓ Branch 0 taken 42599 times.
✓ Branch 1 taken 47952 times.
90551 if(clk<36+66)
9228
2/2
✓ Branch 0 taken 23778 times.
✓ Branch 1 taken 18821 times.
42599 tile=(dir==up)?o_tile+1:o_tile;
9229 else
9230 {
9231 47952 dl=clk-36-66;
9232 waves2:
9233 71470 tile=((dl/11)&1)+s_tile;
9234 71470 basetile = s_tile;
9235 }
9236 }
9237 114069 break;
9238
9239 case aNEWZORA:
9240 {
9241 400124 f4=(clk/16)%4;
9242
9243 400124 tiledir(dir,true);
9244 int32_t dl;
9245
9246
4/4
✓ Branch 0 taken 288116 times.
✓ Branch 1 taken 112008 times.
✓ Branch 2 taken 151092 times.
✓ Branch 3 taken 137024 times.
400124 if((clk>35)&&(clk<36+67)) //surfaced
9247 {
9248
4/4
✓ Branch 0 taken 117068 times.
✓ Branch 1 taken 19956 times.
✓ Branch 2 taken 16724 times.
✓ Branch 3 taken 100344 times.
137024 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
9249 {
9250 100344 tile+=80;
9251 100344 } //mouth closed
9252 else
9253 {
9254 36680 tile+=40;
9255 }
9256
9257 137024 tile+=f4;
9258 137024 }
9259 else
9260 {
9261
2/2
✓ Branch 0 taken 112008 times.
✓ Branch 1 taken 151092 times.
263100 if(clk<36)
9262 {
9263 112008 dl=clk+5;
9264 112008 }
9265 else
9266 {
9267 151092 dl=clk-36-66;
9268 }
9269
9270 263100 tile+=((dl/5)&3);
9271 }
9272 }
9273 400124 break;
9274
9275 case a4FRM4EYE:
9276 case a2FRM4EYE:
9277 case a4FRM8EYE:
9278 case a4FRM8EYEB: //big version
9279 case a4FRM4EYEB:
9280 {
9281 125758 tilerows = 2;
9282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125758 times.
125758 int fakex = x + 8*(zc_max(1,txsz)-1);
9283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125758 times.
125758 int fakey = y + 8*(zc_max(1,tysz)-1);
9284 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9285 125758 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
9286 125758 int32_t lookat=zc_oldrand()&15;
9287
9288
4/4
✓ Branch 0 taken 40954 times.
✓ Branch 1 taken 84804 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 20770 times.
125758 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
9289 {
9290 20770 lookat=l_down;
9291 20770 }
9292
4/4
✓ Branch 0 taken 41154 times.
✓ Branch 1 taken 63834 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 20970 times.
104988 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
9293 {
9294 20970 lookat=down;
9295 20970 }
9296
4/4
✓ Branch 0 taken 33302 times.
✓ Branch 1 taken 50716 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 13118 times.
84018 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
9297 {
9298 13118 lookat=r_down;
9299 13118 }
9300
4/4
✓ Branch 0 taken 31638 times.
✓ Branch 1 taken 39262 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 11454 times.
70900 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
9301 {
9302 11454 lookat=right;
9303 11454 }
9304
4/4
✓ Branch 0 taken 24538 times.
✓ Branch 1 taken 34908 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 4354 times.
59446 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
9305 {
9306 4354 lookat=r_up;
9307 4354 }
9308
4/4
✓ Branch 0 taken 25602 times.
✓ Branch 1 taken 29490 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 5418 times.
55092 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
9309 {
9310 5418 lookat=up;
9311 5418 }
9312
4/4
✓ Branch 0 taken 29766 times.
✓ Branch 1 taken 19908 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 9582 times.
49674 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
9313 {
9314 9582 lookat=l_up;
9315 9582 }
9316 else
9317 {
9318 40092 lookat=left;
9319 }
9320
9321 125758 int32_t dir2 = dir;
9322 125758 dir = lookat;
9323
3/6
✓ Branch 0 taken 125758 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125758 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 125758 times.
125758 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
9324 else
9325 {
9326 tiledir_big(dir,(anim == a4FRM4EYEB));
9327 tile+=2*f4;
9328 ignore_extend = true;
9329 }
9330 125758 dir = dir2;
9331 }
9332 125758 break;
9333
9334 case aFLIP:
9335 {
9336 626088 flip = f2&1;
9337 }
9338 626088 break;
9339
9340 case a2FRM:
9341 {
9342 596152 tile += (1-f2);
9343 }
9344 596152 break;
9345
9346 case a2FRMB:
9347 {
9348 tile+= 2*(1-f2);
9349 ignore_extend = true;
9350 }
9351 break;
9352
9353 case a2FRM4DIR:
9354 {
9355 77420 basetile = n_frame_n_dir(2, 4, f2&1);
9356 }
9357 77420 break;
9358
9359 case a4FRM4DIRF:
9360 {
9361 1882394 basetile = n_frame_n_dir(4,4,f4);
9362
9363
2/2
✓ Branch 0 taken 1190475 times.
✓ Branch 1 taken 691919 times.
1882394 if(clk2>0) //stopped to fire
9364 {
9365 691919 tile+=20;
9366
9367
2/2
✓ Branch 0 taken 332572 times.
✓ Branch 1 taken 359347 times.
691919 if(clk2<17) //firing
9368 {
9369 359347 tile+=20;
9370 359347 }
9371 691919 }
9372 }
9373 1882394 break;
9374
9375 case a4FRM4DIR:
9376 {
9377 3306355 basetile = n_frame_n_dir(4,4,f4);
9378 }
9379 3306355 break;
9380
9381 case a4FRM8DIRF:
9382 {
9383 tilerows = 2;
9384 basetile = n_frame_n_dir(4,8,f4);
9385
9386 if(clk2>0) //stopped to fire
9387 {
9388 tile+=40;
9389
9390 if(clk2<17) //firing
9391 {
9392 tile+=40;
9393 }
9394 }
9395 }
9396 break;
9397
9398 case a4FRM8DIRB:
9399 case a4FRM8DIRFB:
9400 {
9401 3868 tilerows = 2;
9402 3868 tiledir_big(dir,false);
9403 3868 tile+=2*f4;
9404
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
9405 {
9406 tile+=80;
9407
9408 if(clk2<17) //firing
9409 {
9410 tile+=80;
9411 }
9412 }
9413 3868 ignore_extend = true;
9414 }
9415 3868 break;
9416
9417 case a4FRM4DIRB:
9418 case a4FRM4DIRFB:
9419 {
9420 tilerows = 2;
9421 tiledir_big(dir,true);
9422 tile+=2*f4;
9423 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
9424 {
9425 tile+=40;
9426
9427 if(clk2<17) //firing
9428 {
9429 tile+=40;
9430 }
9431 }
9432 ignore_extend = true;
9433 }
9434 break;
9435
9436 case aOCTO:
9437 {
9438
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 35999 times.
✓ Branch 2 taken 39336 times.
✓ Branch 3 taken 47224 times.
✓ Branch 4 taken 38296 times.
160855 switch(dir)
9439 {
9440 case up:
9441 35999 flip = 2;
9442 35999 break;
9443
9444 case down:
9445 39336 flip = 0;
9446 39336 break;
9447
9448 case left:
9449 47224 flip = 0;
9450 47224 tile += 2;
9451 47224 break;
9452
9453 case right:
9454 38296 flip = 1;
9455 38296 tile += 2;
9456 38296 break;
9457 }
9458
9459 160855 tile+=f2;
9460 }
9461 160855 break;
9462
9463 case aWALK:
9464 {
9465
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 61404 times.
✓ Branch 2 taken 71505 times.
✓ Branch 3 taken 92937 times.
✓ Branch 4 taken 93895 times.
319741 switch(dir)
9466 {
9467 case up:
9468 61404 tile+=3;
9469 61404 flip = f2;
9470 61404 break;
9471
9472 case down:
9473 71505 tile+=2;
9474 71505 flip = f2;
9475 71505 break;
9476
9477 case left:
9478 92937 flip=1;
9479 92937 tile += f2;
9480 92937 break;
9481
9482 case right:
9483 93895 flip=0;
9484 93895 tile += f2;
9485 93895 break;
9486 }
9487 }
9488 319741 break;
9489
9490 case aDWALK:
9491 {
9492
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 442753 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
442753 if((get_bit(quest_rules,qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
9493 {
9494 tile=s_tile;
9495 basetile = s_tile;
9496 }
9497
9498
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 91056 times.
✓ Branch 2 taken 91679 times.
✓ Branch 3 taken 128932 times.
✓ Branch 4 taken 131086 times.
442753 switch(dir)
9499 {
9500 case up:
9501 91056 tile+=2;
9502 91056 flip=f2;
9503 91056 break;
9504
9505 case down:
9506 91679 flip=0;
9507 91679 tile+=(1-f2);
9508 91679 break;
9509
9510 case left:
9511 128932 flip=1;
9512 128932 tile+=(3+f2);
9513 128932 break;
9514
9515 case right:
9516 131086 flip=0;
9517 131086 tile+=(3+f2);
9518 131086 break;
9519 }
9520 }
9521 442753 break;
9522
9523 case aTEK:
9524 {
9525
2/2
✓ Branch 0 taken 26984 times.
✓ Branch 1 taken 18674 times.
45658 if(misc==0)
9526 {
9527 18674 tile += f2;
9528 18674 }
9529
2/2
✓ Branch 0 taken 14663 times.
✓ Branch 1 taken 12321 times.
26984 else if(misc!=1)
9530 {
9531 12321 ++tile;
9532 12321 }
9533 }
9534 45658 break;
9535
9536 case aNEWTEK:
9537 {
9538
2/2
✓ Branch 0 taken 300104 times.
✓ Branch 1 taken 892438 times.
1192542 if(step<0) //up
9539 {
9540
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 147182 times.
✓ Branch 2 taken 152922 times.
300104 switch(clk3)
9541 {
9542 case left:
9543 147182 flip=0;
9544 147182 tile+=20;
9545 147182 break;
9546
9547 case right:
9548 152922 flip=0;
9549 152922 tile+=24;
9550 152922 break;
9551 }
9552 300104 }
9553
2/2
✓ Branch 0 taken 38135 times.
✓ Branch 1 taken 854303 times.
892438 else if(step==0)
9554 {
9555
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 28780 times.
✓ Branch 2 taken 9355 times.
38135 switch(clk3)
9556 {
9557 case left:
9558 28780 flip=0;
9559 28780 tile+=8;
9560 28780 break;
9561
9562 case right:
9563 9355 flip=0;
9564 9355 tile+=12;
9565 9355 break;
9566 }
9567 38135 } //down
9568 else
9569 {
9570
3/3
✓ Branch 0 taken 55883 times.
✓ Branch 1 taken 403679 times.
✓ Branch 2 taken 394741 times.
854303 switch(clk3)
9571 {
9572 case left:
9573 403679 flip=0;
9574 403679 tile+=28;
9575 403679 break;
9576
9577 case right:
9578 394741 flip=0;
9579 394741 tile+=32;
9580 394741 break;
9581 }
9582 }
9583
9584
2/2
✓ Branch 0 taken 757764 times.
✓ Branch 1 taken 434778 times.
1192542 if(misc==0)
9585 {
9586 434778 tile+=f4;
9587 434778 }
9588
2/2
✓ Branch 0 taken 367826 times.
✓ Branch 1 taken 389938 times.
757764 else if(misc!=1)
9589 {
9590 389938 tile+=2;
9591 389938 }
9592 }
9593 1192542 break;
9594
9595 case aARMOS:
9596 {
9597
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 1821 times.
2553 if(!fading)
9598 {
9599 1821 tile += fx;
9600
9601
2/2
✓ Branch 0 taken 1151 times.
✓ Branch 1 taken 670 times.
1821 if(dir==up)
9602 670 tile += 2;
9603 1821 }
9604 }
9605 2553 break;
9606
9607 case aARMOS4:
9608 {
9609
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5907 times.
✓ Branch 2 taken 12136 times.
✓ Branch 3 taken 8764 times.
✓ Branch 4 taken 8745 times.
35552 switch(dir)
9610 {
9611 case up:
9612 5907 flip=0;
9613 5907 break;
9614
9615 case down:
9616 12136 flip=0;
9617 12136 tile+=4;
9618 12136 break;
9619
9620 case left:
9621 8764 flip=0;
9622 8764 tile+=8;
9623 8764 break;
9624
9625 case right:
9626 8745 flip=0;
9627 8745 tile+=12;
9628 8745 break;
9629 }
9630
9631
2/2
✓ Branch 0 taken 6441 times.
✓ Branch 1 taken 29111 times.
35552 if(!fading)
9632 {
9633 29111 tile+=f4;
9634 29111 }
9635 }
9636 35552 break;
9637
9638 case aGHINI:
9639 {
9640
3/4
✓ Branch 0 taken 4515 times.
✓ Branch 1 taken 5782 times.
✓ Branch 2 taken 11523 times.
✗ Branch 3 not taken.
21820 switch(dir)
9641 {
9642 case 8:
9643 case 9:
9644 case up:
9645 4515 ++tile;
9646 4515 flip=0;
9647 4515 break;
9648
9649 case 15:
9650 ++tile;
9651 flip=1;
9652 break;
9653
9654 case 10:
9655 case 11:
9656 case right:
9657 5782 flip=1;
9658 5782 break;
9659
9660 default:
9661 11523 flip=0;
9662 11523 break;
9663 }
9664 }
9665 21820 break;
9666
9667 case a2FRMPOS:
9668 {
9669 829242 tile+=posframe;
9670 }
9671 829242 break;
9672
9673 case a4FRMPOS4DIR:
9674 {
9675 216057 basetile = n_frame_n_dir(4,4,0);
9676 // tile+=f2;
9677 216057 tile+=posframe;
9678 }
9679 216057 break;
9680
9681 case a4FRMPOS4DIRF:
9682 {
9683 basetile = n_frame_n_dir(4,4,0);
9684
9685 if(clk2>0) //stopped to fire
9686 {
9687 tile+=20;
9688
9689 if(clk2<17) //firing
9690 {
9691 tile+=20;
9692 }
9693 }
9694
9695 // tile+=f2;
9696 tile+=posframe;
9697 }
9698 break;
9699
9700 case a4FRMPOS8DIR:
9701 {
9702 3036014 tilerows = 2;
9703 3036014 int32_t n = tile;
9704 3036014 basetile = n_frame_n_dir(4,8,0);
9705 // tile+=f2;
9706 3036014 tile+=posframe;
9707 }
9708 3036014 break;
9709
9710 case a4FRMPOS8DIRF:
9711 {
9712 tilerows = 2;
9713 basetile = n_frame_n_dir(4,8,0);
9714
9715 if(clk2>0) //stopped to fire
9716 {
9717 tile+=40;
9718
9719 if(clk2<17) //firing
9720 {
9721 tile+=40;
9722 }
9723 }
9724
9725 tile+=posframe;
9726 }
9727 break;
9728
9729 case aNEWLEV:
9730 {
9731 281252 tiledir(dir,true);
9732
9733
4/5
✓ Branch 0 taken 92728 times.
✓ Branch 1 taken 45439 times.
✓ Branch 2 taken 18283 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124802 times.
281252 switch(misc)
9734 {
9735 case -1:
9736 case 0:
9737 92728 return;
9738
9739 case 1:
9740
9741 // case 5: cs = d->misc2; break;
9742 case 5:
9743 45439 cs = dmisc2;
9744 45439 break;
9745
9746 case 2:
9747 case 4:
9748 18283 tile += 20;
9749 18283 break;
9750
9751 case 3:
9752 124802 tile += 40;
9753 124802 break;
9754 }
9755
9756 188524 tile+=f4;
9757 }
9758 188524 break;
9759
9760 case aLEV:
9761 {
9762 39993 f4 = ((clk/5)&1);
9763
9764
4/5
✓ Branch 0 taken 19248 times.
✓ Branch 1 taken 4577 times.
✓ Branch 2 taken 2268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13900 times.
39993 switch(misc)
9765 {
9766 case -1:
9767 case 0:
9768 19248 return;
9769
9770 case 1:
9771
9772 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
9773 case 5:
9774 4577 tile += (f2) ? 1 : 0;
9775 4577 cs = dmisc2;
9776 4577 break;
9777
9778 case 2:
9779 case 4:
9780 2268 tile += 2;
9781 2268 break;
9782
9783 case 3:
9784 13900 tile += (f4) ? 4 : 3;
9785 13900 break;
9786 }
9787 }
9788 20745 break;
9789
9790 case aWALLM:
9791 {
9792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46675 times.
46675 if(!dummy_bool[1])
9793 {
9794 46675 tile += f2;
9795 46675 }
9796 }
9797 46675 break;
9798
9799 case aNEWWALLM:
9800 {
9801 202996 int32_t tempdir=0;
9802
9803
4/4
✓ Branch 0 taken 26549 times.
✓ Branch 1 taken 19916 times.
✓ Branch 2 taken 5582 times.
✓ Branch 3 taken 150949 times.
202996 switch(misc)
9804 {
9805 case 1:
9806 case 2:
9807 19916 tempdir=clk3;
9808 19916 break;
9809
9810 case 3:
9811 case 4:
9812 case 5:
9813 26549 tempdir=dir;
9814 26549 break;
9815
9816 case 6:
9817 case 7:
9818 5582 tempdir=clk3^1;
9819 5582 break;
9820 }
9821
9822 202996 tiledir(tempdir,true);
9823
9824
2/2
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 202418 times.
202996 if(!dummy_bool[1])
9825 {
9826 202418 tile+=f4;
9827 202418 }
9828 }
9829 202996 break;
9830
9831 case a4FRMNODIR:
9832 {
9833 36233 tile+=f4;
9834 }
9835 36233 break;
9836
9837 } // switch(d->anim)
9838
9839 // flashing
9840 // if(d->flags2 & guy_flashing)
9841
2/2
✓ Branch 0 taken 16769572 times.
✓ Branch 1 taken 356044 times.
17125616 if(flags2 & guy_flashing)
9842 {
9843 356044 cs = (frame&3) + 6;
9844 356044 }
9845
9846
2/2
✓ Branch 0 taken 17093502 times.
✓ Branch 1 taken 32114 times.
17125616 if(flags2&guy_transparent)
9847 {
9848 32114 drawstyle=1;
9849 32114 }
9850
9851 17125616 int32_t change = tile-basetile;
9852
9853
3/6
✓ Branch 0 taken 374939 times.
✓ Branch 1 taken 16750677 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 374939 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17125616 if(extend > 2 && (!ignore_extend || get_bit(quest_rules, qr_BROKEN_BIG_ENEMY_ANIMATION)))
9854 {
9855
2/2
✓ Branch 0 taken 374526 times.
✓ Branch 1 taken 413 times.
374939 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
9856 {
9857 374526 tile=basetile+txsz*change;
9858 374526 }
9859 else
9860 {
9861 413 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
9862 }
9863 374939 }
9864 else
9865 {
9866 16750677 tile=basetile+change;
9867 }
9868 17237734 }
9869
9870 45821 int32_t wpnsfx(int32_t wpn)
9871 {
9872
5/6
✓ Branch 0 taken 17448 times.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 16175 times.
✓ Branch 3 taken 8163 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3804 times.
45821 switch(wpn)
9873 {
9874 case ewFireTrail:
9875 case ewFlame:
9876 case ewFlame2Trail:
9877 case ewFlame2:
9878 17448 return WAV_FIRE;
9879
9880 case ewWind:
9881 case ewMagic:
9882 231 return WAV_WAND;
9883
9884 case ewIce:
9885 return WAV_ZN1ICE;
9886
9887 case ewRock:
9888
2/2
✓ Branch 0 taken 3540 times.
✓ Branch 1 taken 264 times.
3804 if(get_bit(quest_rules,qr_MORESOUNDS)) return WAV_ZN1ROCK;
9889 3540 break;
9890
9891 case ewFireball2:
9892 case ewFireball:
9893
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16168 times.
16175 if(get_bit(quest_rules,qr_MORESOUNDS)) return WAV_ZN1FIREBALL;
9894 16168 }
9895
9896 27871 return -1;
9897 45821 }
9898
9899 31833134 int32_t enemy::run_script(int32_t mode)
9900 {
9901
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31833134 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31833134 if(switch_hooked && !get_bit(quest_rules, qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
9902
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 31833134 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
31833134 if (script <= 0 || !doscript || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
9903 31833134 return RUNSCRIPT_OK;
9904 int32_t ret = RUNSCRIPT_OK;
9905 alloc_scriptmem();
9906 switch(mode)
9907 {
9908 case MODE_NORMAL:
9909 return ZScriptVersion::RunScript(SCRIPT_NPC, script, getUID());
9910 case MODE_WAITDRAW:
9911 if(waitdraw)
9912 {
9913 ret = ZScriptVersion::RunScript(SCRIPT_NPC, script, getUID());
9914 waitdraw = 0;
9915 }
9916 break;
9917 }
9918 return ret;
9919 31833134 }
9920 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
9921 {
9922 return al_map_rgba(255,0,0,opacity);
9923 }
9924 /********************************/
9925 /********* Guy Class **********/
9926 /********************************/
9927
9928 // good guys, fires, fairy, and other non-enemies
9929 // based on enemy class b/c guys in dungeons act sort of like enemies
9930 // also easier to manage all the guys this way
9931 1950 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
9932 1950 {
9933 975 mainguy=mg;
9934 975 canfreeze=false;
9935 975 dir=down;
9936
3/6
✓ Branch 0 taken 975 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 975 times.
✓ Branch 4 taken 975 times.
✗ Branch 5 not taken.
975 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9937 975 hxofs=2;
9938 975 hzsz=8;
9939 975 hxsz=12;
9940 975 hysz=17;
9941
9942
10/12
✓ Branch 0 taken 975 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 975 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 297 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 114 times.
✓ Branch 9 taken 183 times.
✓ Branch 10 taken 11 times.
✓ Branch 11 taken 103 times.
975 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
9943 {
9944 872 superman = 1;
9945 872 hxofs=1000;
9946 872 }
9947 975 }
9948
9949 306271 bool guy::animate(int32_t index)
9950 {
9951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306271 times.
306271 if(switch_hooked) return enemy::animate(index);
9952
6/6
✓ Branch 0 taken 124996 times.
✓ Branch 1 taken 181275 times.
✓ Branch 2 taken 865 times.
✓ Branch 3 taken 124131 times.
✓ Branch 4 taken 424 times.
✓ Branch 5 taken 441 times.
306271 if(mainguy && clk==0 && misc==0)
9953 {
9954 441 setupscreen();
9955 441 misc = 1;
9956 441 }
9957
9958
4/4
✓ Branch 0 taken 124996 times.
✓ Branch 1 taken 181275 times.
✓ Branch 2 taken 124848 times.
✓ Branch 3 taken 148 times.
306271 if(mainguy && fadeclk==0)
9959 148 return true;
9960
9961 306123 hp=256; // good guys never die...
9962
9963
4/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 306039 times.
✓ Branch 2 taken 81 times.
✓ Branch 3 taken 3 times.
306123 if(hclk && !clk2)
9964 {
9965 // but if they get hit...
9966 3 ++clk2; // only do this once
9967
9968
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(!get_bit(quest_rules,qr_NOGUYFIRES))
9969 {
9970 1 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
9971 1 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
9972 1 }
9973 3 }
9974
9975 306123 return enemy::animate(index);
9976 306271 }
9977
9978 308291 void guy::draw(BITMAP *dest)
9979 {
9980 308291 update_enemy_frame();
9981
9982
6/6
✓ Branch 0 taken 126884 times.
✓ Branch 1 taken 181407 times.
✓ Branch 2 taken 10019 times.
✓ Branch 3 taken 116865 times.
✓ Branch 4 taken 5008 times.
✓ Branch 5 taken 5011 times.
308291 if(!mainguy || fadeclk<0 || fadeclk&1)
9983 303280 enemy::draw(dest);
9984 308291 }
9985
9986 /*******************************/
9987 /********* Enemies *********/
9988 /*******************************/
9989
9990 150 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9991 150 {
9992 75 clk4=0;
9993 75 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
9994 // Spawn type
9995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(flags & guy_fadeflicker)
9996 {
9997 clk=0;
9998 superman = 1;
9999 fading=fade_flicker;
10000 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10001 dir=down;
10002
10003 if(!canmove(down,(zfix)8,spw_none,false))
10004 clk3=int32_t(13.0/step);
10005 }
10006
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 else if(flags & guy_fadeinstant)
10007 {
10008 clk=0;
10009 }
10010 75 SIZEflags = d->SIZEflags;
10011
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
75 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10012 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10013 // al_trace("Enemy txsz:%i\n", txsz);
10014
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
75 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10015
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10016
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10017
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10018
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10019
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10020 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10021
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10023 {
10024 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10025 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10026 }
10027
10028
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) d->zofs = (int32_t)zofs;
10029 75 }
10030
10031 39658 bool eFire::animate(int32_t index)
10032 {
10033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39658 times.
39658 if(switch_hooked) return enemy::animate(index);
10034
2/4
✓ Branch 0 taken 39658 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 39658 times.
39658 if(fallclk||drownclk) return enemy::animate(index);
10035
2/2
✓ Branch 0 taken 39430 times.
✓ Branch 1 taken 228 times.
39658 if(fading)
10036 {
10037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(++clk4 > 60)
10038 {
10039 clk4=0;
10040 superman=0;
10041 fading=0;
10042
10043 if(flags2&cmbflag_armos && z==0 && fakez==0)
10044 removearmos(x,y,ffcactivated);
10045
10046 clk2=0;
10047
10048 if(!canmove(down,(zfix)8,spw_none,false))
10049 {
10050 dir=0;
10051 y = y.getInt() & 0xF0;
10052 }
10053
10054 return Dead(index);
10055 }
10056
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
228 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10057 removearmos(x,y,ffcactivated);
10058 228 }
10059
10060 39658 return enemy::animate(index);
10061 39658 }
10062
10063 82490 void eFire::draw(BITMAP *dest)
10064 {
10065 82490 update_enemy_frame();
10066 82490 enemy::draw(dest);
10067 82490 }
10068
10069 97 int32_t eFire::takehit(weapon *w)
10070 {
10071 97 int32_t wpnId = w->id;
10072 97 int32_t wpnDir = w->dir;
10073
10074
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10075 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10076 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10077 {
10078 shield = false;
10079 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10080
10081 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10082 o_tile=s_tile;
10083 }
10084
10085 97 int32_t ret = enemy::takehit(w);
10086 97 return ret;
10087 }
10088
10089 void eFire::break_shield()
10090 {
10091 if(!shield)
10092 return;
10093
10094 flags&=~(inv_front | inv_back | inv_left | inv_right);
10095 shield=false;
10096
10097 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10098 o_tile=s_tile;
10099 }
10100
10101 2556 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10102 2556 {
10103 //zprint2("npct other::other\n");
10104 1278 clk4=0;
10105 1278 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10106
10107 // Spawn type
10108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
1278 if(flags & guy_fadeflicker)
10109 {
10110 clk=0;
10111 superman = 1;
10112 fading=fade_flicker;
10113 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10114 dir=down;
10115
10116 if(!canmove(down,(zfix)8,spw_none,false))
10117 clk3=int32_t(13.0/step);
10118 }
10119
1/2
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
1278 else if(flags & guy_fadeinstant)
10120 {
10121 clk=0;
10122 }
10123 1278 SIZEflags = d->SIZEflags;
10124
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10125 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10126 // al_trace("Enemy txsz:%i\n", txsz);
10127
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10128
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10130
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10131
1/2
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
1278 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10132
1/2
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
1278 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10133 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10134
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
1278 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10136 {
10137 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10138 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10139 }
10140
10141
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10142 1278 }
10143
10144 380627 bool eOther::animate(int32_t index)
10145 {
10146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 380627 times.
380627 if(switch_hooked) return enemy::animate(index);
10147
2/4
✓ Branch 0 taken 380627 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 380627 times.
380627 if(fallclk||drownclk) return enemy::animate(index);
10148 //zprint2("npct other::animate\n");
10149
1/2
✓ Branch 0 taken 380627 times.
✗ Branch 1 not taken.
380627 if(fading)
10150 {
10151 if(++clk4 > 60)
10152 {
10153 clk4=0;
10154 superman=0;
10155 fading=0;
10156
10157 if(flags2&cmbflag_armos && z==0 && fakez==0)
10158 removearmos(x,y,ffcactivated);
10159
10160 clk2=0;
10161
10162 if(!canmove(down,(zfix)8,spw_none,false))
10163 {
10164 dir=0;
10165 y = y.getInt() & 0xF0;
10166 }
10167
10168 return Dead(index);
10169 }
10170 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10171 removearmos(x,y,ffcactivated);
10172 }
10173
10174 380627 return enemy::animate(index);
10175 380627 }
10176
10177 398420 void eOther::draw(BITMAP *dest)
10178 {
10179 398420 update_enemy_frame();
10180 398420 enemy::draw(dest);
10181 398420 }
10182
10183 2767 int32_t eOther::takehit(weapon *w)
10184 {
10185 2767 int32_t wpnId = w->id;
10186 2767 int32_t wpnDir = w->dir;
10187
10188
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2750 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
2767 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10189 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10190 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10191 {
10192 shield = false;
10193 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10194
10195 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10196 o_tile=s_tile;
10197 }
10198
10199 2767 int32_t ret = enemy::takehit(w);
10200 2767 return ret;
10201 }
10202
10203 void eOther::break_shield()
10204 {
10205 if(!shield)
10206 return;
10207
10208 flags&=~(inv_front | inv_back | inv_left | inv_right);
10209 shield=false;
10210
10211 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10212 o_tile=s_tile;
10213 }
10214
10215
10216 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10217 {
10218 clk4=0;
10219 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10220
10221 // Spawn type
10222 if(flags & guy_fadeflicker)
10223 {
10224 clk=0;
10225 superman = 1;
10226 fading=fade_flicker;
10227 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10228 dir=down;
10229
10230 if(!canmove(down,(zfix)8,spw_none,false))
10231 clk3=int32_t(13.0/step);
10232 }
10233 else if(flags & guy_fadeinstant)
10234 {
10235 clk=0;
10236 }
10237 SIZEflags = d->SIZEflags;
10238 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10239 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10240 // al_trace("Enemy txsz:%i\n", txsz);
10241 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10242 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10243 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10244 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10245 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10246 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10247 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10248 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10249 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10250 {
10251 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10252 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10253 }
10254
10255 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10256 }
10257
10258 bool eScript::animate(int32_t index)
10259 {
10260 if(switch_hooked) return enemy::animate(index);
10261 if(fallclk||drownclk) return enemy::animate(index);
10262 if(fading)
10263 {
10264 if(++clk4 > 60)
10265 {
10266 clk4=0;
10267 superman=0;
10268 fading=0;
10269
10270 if(flags2&cmbflag_armos && z==0 && fakez==0)
10271 removearmos(x,y,ffcactivated);
10272
10273 clk2=0;
10274
10275 if(!canmove(down,(zfix)8,spw_none,false))
10276 {
10277 dir=0;
10278 y = y.getInt() & 0xF0;
10279 }
10280
10281 return Dead(index);
10282 }
10283 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10284 removearmos(x,y,ffcactivated);
10285 }
10286
10287 return enemy::animate(index);
10288 }
10289
10290 void eScript::draw(BITMAP *dest)
10291 {
10292 update_enemy_frame();
10293 enemy::draw(dest);
10294 }
10295
10296 int32_t eScript::takehit(weapon *w)
10297 {
10298 int32_t wpnId = w->id;
10299 int32_t wpnDir = w->dir;
10300
10301 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10302 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10303 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10304 {
10305 shield = false;
10306 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10307
10308 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10309 o_tile=s_tile;
10310 }
10311
10312 int32_t ret = enemy::takehit(w);
10313 return ret;
10314 }
10315
10316 void eScript::break_shield()
10317 {
10318 if(!shield)
10319 return;
10320
10321 flags&=~(inv_front | inv_back | inv_left | inv_right);
10322 shield=false;
10323
10324 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10325 o_tile=s_tile;
10326 }
10327
10328
10329 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10330 {
10331 clk4=0;
10332 hyofs = -32768; //No hitbox initially.
10333 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10334
10335 // Spawn type
10336 if(flags & guy_fadeflicker)
10337 {
10338 clk=0;
10339 superman = 1;
10340 fading=fade_flicker;
10341 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10342 dir=down;
10343
10344 if(!canmove(down,(zfix)8,spw_none,false))
10345 clk3=int32_t(13.0/step);
10346 }
10347 else if(flags & guy_fadeinstant)
10348 {
10349 clk=0;
10350 }
10351 SIZEflags = d->SIZEflags;
10352 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10353 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10354 // al_trace("Enemy txsz:%i\n", txsz);
10355 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10356 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10357 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10358 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10359 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10360 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10361 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10362 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10363 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10364 {
10365 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10366 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10367 }
10368
10369 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10370 }
10371
10372 bool eFriendly::animate(int32_t index)
10373 {
10374 if(switch_hooked) return enemy::animate(index);
10375 if(fallclk||drownclk) return enemy::animate(index);
10376 if(fading)
10377 {
10378 if(++clk4 > 60)
10379 {
10380 clk4=0;
10381 superman=0;
10382 fading=0;
10383
10384 if(flags2&cmbflag_armos && z==0 && fakez==0)
10385 removearmos(x,y,ffcactivated);
10386
10387 clk2=0;
10388
10389 if(!canmove(down,(zfix)8,spw_none,false))
10390 {
10391 dir=0;
10392 y = y.getInt() & 0xF0;
10393 }
10394
10395 return Dead(index);
10396 }
10397 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10398 removearmos(x,y,ffcactivated);
10399 }
10400
10401 return enemy::animate(index);
10402 }
10403
10404 void eFriendly::draw(BITMAP *dest)
10405 {
10406 update_enemy_frame();
10407 enemy::draw(dest);
10408 }
10409
10410 int32_t eFriendly::takehit(weapon *w)
10411 {
10412 int32_t wpnId = w->id;
10413 int32_t wpnDir = w->dir;
10414
10415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10416 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10417 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10418 {
10419 shield = false;
10420 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10421
10422 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10423 o_tile=s_tile;
10424 }
10425
10426 int32_t ret = enemy::takehit(w);
10427 return ret;
10428 }
10429
10430 void eFriendly::break_shield()
10431 {
10432 if(!shield)
10433 return;
10434
10435 flags&=~(inv_front | inv_back | inv_left | inv_right);
10436 shield=false;
10437
10438 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10439 o_tile=s_tile;
10440 }
10441
10442
10443 283483 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
10444 {
10445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 283483 times.
283483 if (ffcactive)
10446 {
10447 removearmosffc(ffcactive-1);
10448 return;
10449 }
10450
2/2
✓ Branch 0 taken 282929 times.
✓ Branch 1 taken 554 times.
283483 if(did_armos)
10451 {
10452 282929 return;
10453 }
10454
10455 554 did_armos=true;
10456 554 ax&=0xF0;
10457 554 ay&=0xF0;
10458 554 int32_t cd = (ax>>4)+ay;
10459 554 int32_t f = MAPFLAG(ax,ay);
10460 554 int32_t f2 = MAPCOMBOFLAG(ax,ay);
10461
10462
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 92 times.
554 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
10463 {
10464 462 return;
10465 }
10466
10467 92 tmpscr->data[cd] = tmpscr->undercombo;
10468 92 tmpscr->cset[cd] = tmpscr->undercset;
10469 92 tmpscr->sflag[cd] = 0;
10470
10471
3/4
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
92 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
10472 {
10473 20 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
10474 20 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
10475 20 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
10476 20 sfx(tmpscr->secretsfx);
10477 20 }
10478
10479
3/4
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
92 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
10480 {
10481
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
10482 {
10483 1 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
10484 1 sfx(tmpscr->secretsfx);
10485 1 }
10486 1 }
10487
10488 92 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
10489 283483 }
10490
10491 void enemy::removearmosffc(int32_t pos)
10492 {
10493 if(did_armos)
10494 {
10495 return;
10496 }
10497
10498 did_armos=true;
10499 ffcdata& ffc = tmpscr->ffcs[pos];
10500 newcombo const& cmb = combobuf[ffc.getData()];
10501 int32_t f2 = cmb.flag;
10502
10503 if(cmb.type!=cARMOS)
10504 {
10505 return;
10506 }
10507
10508 ffc.setData(tmpscr->undercombo);
10509 ffc.cset = tmpscr->undercset;
10510
10511 if(f2 == mfARMOS_SECRET)
10512 {
10513 ffc.setData(tmpscr->secretcombo[sSTAIRS]);
10514 ffc.cset = tmpscr->secretcset[sSTAIRS];
10515 sfx(tmpscr->secretsfx);
10516 }
10517
10518 if(f2 == mfARMOS_ITEM)
10519 {
10520 if(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
10521 {
10522 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
10523 sfx(tmpscr->secretsfx);
10524 }
10525 }
10526
10527 putcombo(scrollbuf,ffc.x,ffc.y,ffc.getData(),ffc.cset);
10528 }
10529
10530
10531 258 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10532 258 {
10533 129 fading=fade_flicker;
10534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10535 129 dir=12;
10536 129 movestatus=1;
10537
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 step=0;
10538 129 clk=0;
10539 129 clk4=0;
10540 129 SIZEflags = d->SIZEflags;
10541
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10542 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10543 // al_trace("Enemy txsz:%i\n", txsz);
10544
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10545
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10546
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10547
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10548
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10549
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10550 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10551
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10553 {
10554 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10555 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10556 }
10557
10558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10559 129 }
10560
10561 48119 bool eGhini::animate(int32_t index)
10562 {
10563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48119 times.
48119 if(switch_hooked) return enemy::animate(index);
10564
2/4
✓ Branch 0 taken 48119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 48119 times.
48119 if(fallclk||drownclk) return enemy::animate(index);
10565
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 48083 times.
48119 if(dying)
10566 36 return Dead(index);
10567
10568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48083 times.
48083 if(dmisc1)
10569 {
10570
2/2
✓ Branch 0 taken 40347 times.
✓ Branch 1 taken 7736 times.
48083 if(misc)
10571 {
10572
2/2
✓ Branch 0 taken 10797 times.
✓ Branch 1 taken 29550 times.
40347 if(clk4>160)
10573 29550 misc=2;
10574
10575
2/2
✓ Branch 0 taken 10797 times.
✓ Branch 1 taken 29550 times.
40347 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
10576 40347 removearmos(x,y,ffcactivated);
10577 40347 }
10578
2/2
✓ Branch 0 taken 7612 times.
✓ Branch 1 taken 124 times.
7736 else if(clk4>=60)
10579 {
10580 124 misc=1;
10581 124 clk3=32;
10582 124 fading=0;
10583
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if (ffcactivated > 0)
10584 {
10585 guygridffc[ffcactivated-1] = 0;
10586 removearmosffc(ffcactivated-1);
10587 }
10588 else
10589 {
10590 124 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
10591 124 removearmos(x,y);
10592 }
10593 124 }
10594 48083 }
10595
10596 48083 clk4++;
10597
10598 48083 return enemy::animate(index);
10599 48119 }
10600
10601 96296 void eGhini::draw(BITMAP *dest)
10602 {
10603 96296 update_enemy_frame();
10604 96296 enemy::draw(dest);
10605 96296 }
10606
10607 2 void eGhini::kickbucket()
10608 {
10609 2 hp=-1000; // don't call death_sfx()
10610 2 }
10611
10612
3/6
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2000 times.
✗ Branch 5 not taken.
6000 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10613 4000 {
10614
1/2
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
2000 old_y=y;
10615 2000 dir=down;
10616 2000 misc=1;
10617 2000 clk=-15;
10618
10619
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 20 times.
2000 if(!BSZ)
10620
1/2
✓ Branch 0 taken 1980 times.
✗ Branch 1 not taken.
1980 clk*=zc_oldrand()%3+1;
10621
10622 // avoid divide by 0 errors
10623
1/2
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
2000 if(dmisc1 == 0)
10624 dmisc1 = 24;
10625
10626
1/2
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
2000 if(dmisc2 == 0)
10627 dmisc2 = 3;
10628
10629 //nets+760;
10630 2000 SIZEflags = d->SIZEflags;
10631
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2000 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10632 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10633 // al_trace("Enemy txsz:%i\n", txsz);
10634
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2000 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10635
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2000 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10636
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2000 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10637
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2000 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10638
1/2
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
2000 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10639
1/2
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
2000 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10640 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10641
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2000 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
2000 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10643 {
10644 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10645 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10646 }
10647
10648
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2000 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10649 2000 }
10650
10651 667342 bool eTektite::animate(int32_t index)
10652 {
10653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 667342 times.
667342 if(switch_hooked) return enemy::animate(index);
10654
4/4
✓ Branch 0 taken 663848 times.
✓ Branch 1 taken 3494 times.
✓ Branch 2 taken 3494 times.
✓ Branch 3 taken 667150 times.
667342 if(fallclk||drownclk) return enemy::animate(index);
10655
2/2
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 651279 times.
667150 if(dying)
10656 15871 return Dead(index);
10657
10658
2/2
✓ Branch 0 taken 634714 times.
✓ Branch 1 taken 16565 times.
651279 if(clk==0)
10659 {
10660 16565 removearmos(x,y,ffcactivated);
10661 16565 }
10662
10663
2/2
✓ Branch 0 taken 318145 times.
✓ Branch 1 taken 333134 times.
651279 if(get_bit(quest_rules,qr_ENEMIESZAXIS))
10664 {
10665 333134 y=floor_y;
10666 333134 }
10667
10668
9/10
✓ Branch 0 taken 588492 times.
✓ Branch 1 taken 62787 times.
✓ Branch 2 taken 583908 times.
✓ Branch 3 taken 4584 times.
✓ Branch 4 taken 583908 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9135 times.
✓ Branch 7 taken 574773 times.
✓ Branch 8 taken 4678 times.
✓ Branch 9 taken 7807 times.
651279 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
10669 {
10670
4/4
✓ Branch 0 taken 6652 times.
✓ Branch 1 taken 233632 times.
✓ Branch 2 taken 150023 times.
✓ Branch 3 taken 192273 times.
582580 switch(misc)
10671 {
10672 case 0: // normal
10673
2/2
✓ Branch 0 taken 228759 times.
✓ Branch 1 taken 4873 times.
233632 if(!(zc_oldrand()%dmisc1))
10674 {
10675 4873 misc=1;
10676 4873 clk2=32;
10677 4873 }
10678
10679 233632 break;
10680
10681 case 1: // waiting to pounce
10682
2/2
✓ Branch 0 taken 142162 times.
✓ Branch 1 taken 7861 times.
150023 if(--clk2<=0)
10683 {
10684 7861 int32_t r=zc_oldrand();
10685 7861 misc=2;
10686 7861 step=0-(zslongToFix(dstep*100)); // initial speed
10687 7861 clk3=(r&1)+2; // left or right
10688 7861 clk2start=clk2=(r&31)+10; // flight time
10689
10690
2/2
✓ Branch 0 taken 6859 times.
✓ Branch 1 taken 1002 times.
7861 if(y<32) clk2+=2; // make them come down from top of screen
10691
10692
2/2
✓ Branch 0 taken 6049 times.
✓ Branch 1 taken 1812 times.
7861 if(y>112) clk2-=2; // make them go back up
10693
10694 7861 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
10695 7861 }
10696
10697 150023 break;
10698
10699 case 2: // in flight
10700 192273 move(step);
10701
10702
2/2
✓ Branch 0 taken 92728 times.
✓ Branch 1 taken 99545 times.
192273 if(step>0) //going down
10703 {
10704
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 92572 times.
92728 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
10705 {
10706 156 step=0-step;
10707 156 }
10708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92572 times.
92572 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
10709 {
10710 step=0-step;
10711 }
10712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92572 times.
92572 else if(ispitfall(x+8,y+16))
10713 {
10714 step=0-step;
10715 }
10716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92572 times.
92572 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
10717 {
10718 step=0-step;
10719 }
10720
1/2
✓ Branch 0 taken 92572 times.
✗ Branch 1 not taken.
92572 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
10721 {
10722 step=0-step;
10723 }
10724 92728 }
10725
2/2
✓ Branch 0 taken 6392 times.
✓ Branch 1 taken 93153 times.
99545 else if(step<0)
10726 {
10727
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 92934 times.
93153 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
10728 {
10729 219 step=0-step;
10730 219 }
10731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92934 times.
92934 else if(COMBOTYPE(x+8,y)==cNOENEMY)
10732 {
10733 step=0-step;
10734 }
10735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92934 times.
92934 else if(ispitfall(x+8,y))
10736 {
10737 step=0-step;
10738 }
10739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92934 times.
92934 else if(MAPFLAG(x+8,y)==mfNOENEMY)
10740 {
10741 step=0-step;
10742 }
10743
1/2
✓ Branch 0 taken 92934 times.
✗ Branch 1 not taken.
92934 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
10744 {
10745 step=0-step;
10746 }
10747 93153 }
10748
10749
2/2
✓ Branch 0 taken 95192 times.
✓ Branch 1 taken 97081 times.
192273 if(clk3==left)
10750 {
10751
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 95091 times.
95192 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
10752 {
10753 101 clk3^=1;
10754 101 }
10755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95091 times.
95091 else if(COMBOTYPE(x,y+8)==cNOENEMY)
10756 {
10757 clk3^=1;
10758 }
10759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95091 times.
95091 else if(ispitfall(x,y+8))
10760 {
10761 clk3^=1;
10762 }
10763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95091 times.
95091 else if(MAPFLAG(x,y+8)==mfNOENEMY)
10764 {
10765 clk3^=1;
10766 }
10767
1/2
✓ Branch 0 taken 95091 times.
✗ Branch 1 not taken.
95091 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
10768 {
10769 clk3^=1;
10770 }
10771 95192 }
10772 else
10773 {
10774
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 96990 times.
97081 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
10775 {
10776 91 clk3^=1;
10777 91 }
10778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96990 times.
96990 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
10779 {
10780 clk3^=1;
10781 }
10782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96990 times.
96990 else if(ispitfall(x+16,y+8))
10783 {
10784 clk3^=1;
10785 }
10786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96990 times.
96990 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
10787 {
10788 clk3^=1;
10789 }
10790
1/2
✓ Branch 0 taken 96990 times.
✗ Branch 1 not taken.
96990 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
10791 {
10792 clk3^=1;
10793 }
10794 }
10795
10796 192273 --c;
10797
10798
4/4
✓ Branch 0 taken 57956 times.
✓ Branch 1 taken 134317 times.
✓ Branch 2 taken 126621 times.
✓ Branch 3 taken 65652 times.
192273 if(c<0 && step<zslongToFix(dstep*100))
10799 {
10800 65652 step+=zslongToFix(dmisc3*100);
10801 65652 }
10802
10803 192273 int32_t nb=get_bit(quest_rules,qr_NOBORDER) ? 16 : 0;
10804
10805
2/2
✓ Branch 0 taken 192072 times.
✓ Branch 1 taken 201 times.
192273 if(x<=16-nb) clk3=right;
10806
10807
2/2
✓ Branch 0 taken 191876 times.
✓ Branch 1 taken 397 times.
192273 if(x>=224+nb) clk3=left;
10808
10809 192273 x += (clk3==left) ? -1 : 1;
10810
10811
4/4
✓ Branch 0 taken 10761 times.
✓ Branch 1 taken 181512 times.
✓ Branch 2 taken 3326 times.
✓ Branch 3 taken 178186 times.
192273 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
10812 {
10813
4/4
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 6993 times.
✓ Branch 2 taken 265 times.
✓ Branch 3 taken 177 times.
14087 if(y>=144+nb && get_bit(quest_rules,qr_ENEMIESZAXIS))
10814 {
10815 177 step=0-step;
10816 177 y--;
10817 177 }
10818
2/2
✓ Branch 0 taken 5692 times.
✓ Branch 1 taken 1566 times.
7258 else if(zc_oldrand()%dmisc2) //land and wait
10819 {
10820 5692 clk=misc=0;
10821 5692 } //land and jump again
10822 else
10823 {
10824 1566 misc=1;
10825 1566 clk2=0;
10826 }
10827 7435 }
10828
10829 185621 break;
10830 } // switch
10831 575928 }
10832
10833
4/4
✓ Branch 0 taken 333134 times.
✓ Branch 1 taken 314843 times.
✓ Branch 2 taken 226451 times.
✓ Branch 3 taken 106683 times.
647977 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && misc==2)
10834 {
10835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106683 times.
106683 if (moveflags & FLAG_USE_FAKE_Z)
10836 {
10837 int32_t tempy = floor_y;
10838 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
10839 floor_y = y;
10840 y=tempy-fakez;
10841 old_y = y;
10842 }
10843 else
10844 {
10845 106683 int32_t tempy = floor_y;
10846
6/6
✓ Branch 0 taken 53507 times.
✓ Branch 1 taken 53176 times.
✓ Branch 2 taken 2353 times.
✓ Branch 3 taken 104330 times.
✓ Branch 4 taken 52359 times.
✓ Branch 5 taken 51971 times.
106683 z=zc_max(0,zc_min(clk2start-clk2,clk2));
10847 106683 floor_y = y;
10848 106683 y=tempy-z;
10849 106683 old_y = y;
10850 }
10851 106683 }
10852
10853
4/4
✓ Branch 0 taken 4584 times.
✓ Branch 1 taken 643393 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 3669 times.
647977 if(stunclk && (clk&31)==1)
10854 3669 clk=0;
10855
10856 647977 return enemy::animate(index);
10857 663848 }
10858
10859 205276 void eTektite::drawshadow(BITMAP *dest,bool translucent)
10860 {
10861
5/6
✓ Branch 0 taken 35720 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 35720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11386 times.
✓ Branch 5 taken 24334 times.
205276 if(z<1 && fakez<1 && get_bit(quest_rules,qr_ENEMIESZAXIS))
10862 24334 return;
10863
10864 180942 int32_t tempy=yofs;
10865 180942 int32_t fdiv = frate/4;
10866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180942 times.
180942 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
10867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180942 times.
180942 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
10868 180942 efrate:((clk>=(frate>>1))?1:0);
10869 180942 flip = 0;
10870 180942 shadowtile = wpnsbuf[spr_shadow].tile;
10871
10872
1/2
✓ Branch 0 taken 180942 times.
✗ Branch 1 not taken.
180942 if(get_bit(quest_rules,qr_NEWENEMYTILES))
10873 {
10874
2/2
✓ Branch 0 taken 68140 times.
✓ Branch 1 taken 112802 times.
180942 if(misc==0)
10875 {
10876 68140 shadowtile+=f2;
10877 68140 }
10878
2/2
✓ Branch 0 taken 50479 times.
✓ Branch 1 taken 62323 times.
112802 else if(misc!=1)
10879 62323 shadowtile+=2;
10880 180942 }
10881 else
10882 {
10883 if(misc==0)
10884 {
10885 shadowtile += f2 ? 1 : 0;
10886 }
10887 else if(misc!=1)
10888 {
10889 ++shadowtile;
10890 }
10891 }
10892
10893 180942 yofs+=8;
10894
10895
4/4
✓ Branch 0 taken 11386 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 5992 times.
✓ Branch 3 taken 5394 times.
180942 if(!get_bit(quest_rules,qr_ENEMIESZAXIS) && misc==2)
10896 {
10897
6/6
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 2716 times.
✓ Branch 2 taken 320 times.
✓ Branch 3 taken 5074 times.
✓ Branch 4 taken 2572 times.
✓ Branch 5 taken 2502 times.
5394 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
10898 5394 }
10899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180942 times.
180942 if(!shadow_overpit(this))
10900 180942 enemy::drawshadow(dest,translucent);
10901 180942 yofs=tempy;
10902 205276 }
10903
10904 1258976 void eTektite::draw(BITMAP *dest)
10905 {
10906 1258976 update_enemy_frame();
10907 1258976 enemy::draw(dest);
10908 1258976 }
10909
10910 606 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10911 606 {
10912
2/4
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 303 times.
✗ Branch 3 not taken.
303 step=zslongToFix(guysbuf[id&0xFFF].step*100);
10913 303 superman=1;
10914 303 dir=8;
10915 303 hxofs=1000;
10916 303 mainguy=false;
10917 303 count_enemy=false;
10918
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
303 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10919 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10920 // al_trace("Enemy txsz:%i\n", txsz);
10921
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
303 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
10922
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
303 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
10923
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
303 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
10924
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
303 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
10925
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
10926
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
10927 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10928
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
303 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
10929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
303 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10930 {
10931 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
10932 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10933 }
10934
10935
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
303 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
10936 303 }
10937
10938 176141 bool eItemFairy::animate(int32_t index)
10939 {
10940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 176141 times.
176141 if(switch_hooked) return enemy::animate(index);
10941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 176141 times.
176141 if(dying)
10942 return Dead(index);
10943
10944 //if(clk>32)
10945 176141 misc=1;
10946 176141 bool w=watch;
10947 176141 watch=false;
10948 176141 variable_walk_8(misc?3:0,0,8,spw_floater);
10949 176141 watch=w;
10950
10951
2/2
✓ Branch 0 taken 848 times.
✓ Branch 1 taken 175293 times.
176141 if(clk==0)
10952 {
10953 848 removearmos(x,y,ffcactivated);
10954 848 }
10955
10956 176141 return enemy::animate(index);
10957 176141 }
10958
10959 352742 void eItemFairy::draw(BITMAP *dest)
10960 {
10961 //these are here to bypass compiler warnings about unused arguments
10962 352742 dest=dest;
10963 352742 }
10964
10965 1486 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10966 1486 {
10967 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
10968
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✓ Branch 2 taken 743 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 743 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 743 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 743 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 743 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 743 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 743 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 743 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 743 times.
✗ Branch 19 not taken.
743 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
10969 743 dir=8;
10970 743 movestatus=1;
10971 743 clk=0;
10972
1/2
✓ Branch 0 taken 743 times.
✗ Branch 1 not taken.
743 step=0;
10973 //nets+720;
10974 743 SIZEflags = d->SIZEflags;
10975
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
743 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10976 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10977 // al_trace("Enemy txsz:%i\n", txsz);
10978
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
743 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10979
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
743 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10980
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
743 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10981
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
743 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10982
1/2
✓ Branch 0 taken 743 times.
✗ Branch 1 not taken.
743 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10983
1/2
✓ Branch 0 taken 743 times.
✗ Branch 1 not taken.
743 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10984 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10985
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
743 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
743 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10987 {
10988 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10989 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10990 }
10991
10992
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
743 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10993 743 }
10994
10995 225799 bool ePeahat::animate(int32_t index)
10996 {
10997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 225799 times.
225799 if(switch_hooked) return enemy::animate(index);
10998
2/4
✓ Branch 0 taken 225799 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 225799 times.
225799 if(fallclk||drownclk) return enemy::animate(index);
10999
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 225721 times.
225799 if(slide())
11000 {
11001 78 return false;
11002 }
11003
11004
2/2
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 225235 times.
225721 if(dying)
11005 486 return Dead(index);
11006
11007
2/2
✓ Branch 0 taken 223867 times.
✓ Branch 1 taken 1368 times.
225235 if(clk==0)
11008 {
11009 1368 removearmos(x,y,ffcactivated);
11010 1368 }
11011
11012
4/4
✓ Branch 0 taken 222455 times.
✓ Branch 1 taken 2780 times.
✓ Branch 2 taken 106275 times.
✓ Branch 3 taken 116180 times.
225235 if(stunclk==0 && clk>96)
11013 116180 misc=1;
11014
11015
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 222833 times.
225235 if(!watch)
11016
2/2
✓ Branch 0 taken 149857 times.
✓ Branch 1 taken 72976 times.
222833 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
11017
11018
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 125217 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
225235 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11019 {
11020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100018 times.
100018 if (moveflags & FLAG_USE_FAKE_Z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
11021 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
11022 100018 }
11023
11024
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 222833 times.
✓ Branch 2 taken 1634 times.
✓ Branch 3 taken 768 times.
225235 if(watch && get_bit(quest_rules,qr_PEAHATCLOCKVULN))
11025 1634 superman=0;
11026 else
11027
2/2
✓ Branch 0 taken 217412 times.
✓ Branch 1 taken 6189 times.
223601 superman=(movestatus && !get_bit(quest_rules,qr_ENEMIESZAXIS)) ? 1 : 0;
11028 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
11029
2/2
✓ Branch 0 taken 196019 times.
✓ Branch 1 taken 29216 times.
225235 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
11030 {
11031
2/2
✓ Branch 0 taken 2777 times.
✓ Branch 1 taken 193242 times.
196019 if ( stunclk ) --stunclk;
11032 196019 }
11033 29216 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
11034 //Pretty sure this was always an error. -Z ( 14FEB2019 )
11035
11036
11037
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 225015 times.
225235 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
11038
11039 225235 return enemy::animate(index);
11040 225799 }
11041
11042 88089 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
11043 {
11044 88089 int32_t tempy=yofs;
11045 88089 flip = 0;
11046 88089 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11047
11048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88089 times.
88089 if(!get_bit(quest_rules,qr_ENEMIESZAXIS))
11049 {
11050 yofs+=8;
11051 yofs+=int32_t(step/zslongToFix(dstep*10));
11052 }
11053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88089 times.
88089 if(!shadow_overpit(this))
11054 88089 enemy::drawshadow(dest,translucent);
11055 88089 yofs=tempy;
11056 88089 }
11057
11058 545420 void ePeahat::draw(BITMAP *dest)
11059 {
11060 545420 update_enemy_frame();
11061 545420 enemy::draw(dest);
11062 545420 }
11063
11064 817 int32_t ePeahat::takehit(weapon *w)
11065 {
11066 817 int32_t wpnId = w->id;
11067 817 int32_t enemyHitWeapon = w->parentitem;
11068
11069
3/6
✓ Branch 0 taken 817 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 817 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 817 times.
817 if(dying || clk<0 || hclk>0)
11070 return 0;
11071
11072
4/4
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 102 times.
949 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
11073 // fire boomerang, for nailing peahats
11074
4/6
✓ Branch 0 taken 623 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 491 times.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 132 times.
623 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
11075 593 return 0;
11076
11077 // Time for a kludge...
11078 224 int32_t s = superman;
11079 224 superman = 0;
11080 224 int32_t ret = enemy::takehit(w);
11081 224 superman = s;
11082
11083 // Anyway...
11084
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 141 times.
224 if(stunclk == 160)
11085 {
11086 141 clk2=0;
11087 141 movestatus=0;
11088 141 misc=0;
11089 141 clk=0;
11090 141 step=0;
11091 141 }
11092
11093 224 return ret;
11094 817 }
11095
11096 // auomatically kill off enemy (for rooms with ringleaders)
11097 void ePeahat::kickbucket()
11098 {
11099 hp=-1000; // don't call death_sfx()
11100 }
11101
11102 2194 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11103 2194 {
11104 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
11105
2/2
✓ Branch 0 taken 493 times.
✓ Branch 1 taken 604 times.
1097 if(dmisc1==0)
11106 {
11107 604 misc=-1; //Line of Sight leevers
11108 604 clk-=16;
11109 604 }
11110 1097 clk3 = 0;
11111 //nets+1460;
11112
1/2
✓ Branch 0 taken 1097 times.
✗ Branch 1 not taken.
1097 temprule=(get_bit(quest_rules,qr_NEWENEMYTILES)) != 0;
11113 1097 submerged = false;
11114 1097 SIZEflags = d->SIZEflags;
11115
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1097 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11116 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11117 // al_trace("Enemy txsz:%i\n", txsz);
11118
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1097 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11119
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1097 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11120
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1097 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11121
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1097 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11122
1/2
✓ Branch 0 taken 1097 times.
✗ Branch 1 not taken.
1097 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11123
1/2
✓ Branch 0 taken 1097 times.
✗ Branch 1 not taken.
1097 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11124 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11125
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1097 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
1097 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11127 {
11128 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11129 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11130 }
11131
11132
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1097 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11133 1097 }
11134
11135 bool eLeever::isSubmerged() const
11136 {
11137 Z_scripterrlog("misc is: %d\n", misc);
11138 return misc <= 0;
11139
11140 }
11141
11142 320425 bool eLeever::animate(int32_t index)
11143 {
11144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320425 times.
320425 if(switch_hooked) return enemy::animate(index);
11145
2/4
✓ Branch 0 taken 320425 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 320425 times.
320425 if(fallclk||drownclk)
11146 {
11147 return enemy::animate(index);
11148 }
11149
2/2
✓ Branch 0 taken 12312 times.
✓ Branch 1 taken 308113 times.
320425 if(dying)
11150 12312 return Dead(index);
11151
11152
2/2
✓ Branch 0 taken 291344 times.
✓ Branch 1 taken 16769 times.
308113 if(clk==0)
11153 {
11154 16769 removearmos(x,y,ffcactivated);
11155 16769 }
11156
11157
4/4
✓ Branch 0 taken 255376 times.
✓ Branch 1 taken 52737 times.
✓ Branch 2 taken 1847 times.
✓ Branch 3 taken 253529 times.
308113 if(clk>=0 && !slide())
11158 {
11159 // switch(d->misc1)
11160
2/2
✓ Branch 0 taken 90190 times.
✓ Branch 1 taken 163339 times.
253529 switch(dmisc1)
11161 {
11162 case 0: //line of sight
11163 case 2:
11164
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 30948 times.
✓ Branch 2 taken 8626 times.
✓ Branch 3 taken 11370 times.
✓ Branch 4 taken 5067 times.
✓ Branch 5 taken 30855 times.
✓ Branch 6 taken 1287 times.
✓ Branch 7 taken 2037 times.
90190 switch(misc) //is this leever active
11165 {
11166 case -1: //submerged
11167 {
11168
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30948 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30948 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
11169
4/4
✓ Branch 0 taken 7609 times.
✓ Branch 1 taken 23339 times.
✓ Branch 2 taken 7582 times.
✓ Branch 3 taken 27 times.
30948 if((dmisc1==2)&&(zc_oldrand()&255))
11170 {
11171 7582 break;
11172 }
11173
11174 23366 int32_t active=0;
11175
11176
2/2
✓ Branch 0 taken 130512 times.
✓ Branch 1 taken 23366 times.
153878 for(int32_t i=0; i<guys.Count(); i++)
11177 {
11178
4/4
✓ Branch 0 taken 113163 times.
✓ Branch 1 taken 17349 times.
✓ Branch 2 taken 67249 times.
✓ Branch 3 taken 45914 times.
130512 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
11179 {
11180 45914 ++active;
11181 45914 }
11182 130512 }
11183
11184
2/2
✓ Branch 0 taken 22791 times.
✓ Branch 1 taken 575 times.
23366 if(active<((dmisc1==2)?1:2))
11185 {
11186 575 misc=0; //activate this one
11187 575 clk3=1; //This needs to be set so that it knows that it's being emerged of it's own will and not because it got stunned.
11188 575 }
11189 }
11190 23366 break;
11191
11192 case 0:
11193 {
11194
11195
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8626 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8626 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
11196 {
11197 misc=1;
11198 clk2=0;
11199 }
11200
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 8590 times.
8626 else if (clk3<=0)
11201 {
11202 36 misc = -1;
11203 36 break;
11204 }
11205 8590 int32_t s=0;
11206
11207
2/2
✓ Branch 0 taken 54807 times.
✓ Branch 1 taken 8590 times.
63397 for(int32_t i=0; i<guys.Count(); i++)
11208 {
11209
4/4
✓ Branch 0 taken 25493 times.
✓ Branch 1 taken 29314 times.
✓ Branch 2 taken 23967 times.
✓ Branch 3 taken 1526 times.
54807 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
11210 {
11211 1526 ++s;
11212 1526 }
11213 54807 }
11214
11215
2/2
✓ Branch 0 taken 1526 times.
✓ Branch 1 taken 7064 times.
8590 if(s>0)
11216 {
11217 1526 break;
11218 }
11219
11220 7064 int32_t d2=zc_oldrand()&1;
11221
11222
2/2
✓ Branch 0 taken 1399 times.
✓ Branch 1 taken 5665 times.
7064 if(HeroDir()>=left)
11223 {
11224 5665 d2+=2;
11225 5665 }
11226
11227
4/4
✓ Branch 0 taken 6610 times.
✓ Branch 1 taken 454 times.
✓ Branch 2 taken 220 times.
✓ Branch 3 taken 6390 times.
7064 if(canplace(d2) || canplace(d2^1))
11228 {
11229 674 misc=1;
11230 674 clk2=0;
11231 674 clk=0;
11232 674 }
11233 }
11234 7064 break;
11235
11236 case 1:
11237
11238
3/8
✓ Branch 0 taken 10706 times.
✓ Branch 1 taken 664 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10706 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
11370 if(++clk2>16||(!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
11239
11240 11370 break;
11241
11242 case 2:
11243
11244
3/8
✓ Branch 0 taken 4451 times.
✓ Branch 1 taken 616 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4451 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5067 if(++clk2>24||(!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
11245
11246 5067 break;
11247
11248 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
11249 case 3:
11250
11251
5/6
✓ Branch 0 taken 28833 times.
✓ Branch 1 taken 2022 times.
✓ Branch 2 taken 28833 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 914 times.
✓ Branch 5 taken 27919 times.
30855 if(stunclk || frozenclock || watch) break;
11252
11253
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 27861 times.
27919 if(scored) dir^=1;
11254
11255
2/2
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 27770 times.
27919 if(!canmove(dir,false)) misc=4;
11256 27770 else move(zslongToFix(dstep*100));
11257
11258 27919 break;
11259
11260 case 4:
11261
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1287 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
11262
2/2
✓ Branch 0 taken 1150 times.
✓ Branch 1 taken 137 times.
1287 if(--clk2<=16)
11263 {
11264 137 misc=5;
11265 137 clk=8;
11266 137 }
11267
11268 1287 break;
11269
11270 case 5:
11271
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2037 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2037 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
11272
2/2
✓ Branch 0 taken 1913 times.
✓ Branch 1 taken 124 times.
2037 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
11273
11274 2037 break;
11275 } // switch(misc)
11276
11277 90190 break;
11278
11279 default: //random
11280 // step=d->misc3/100.0;
11281
11282 163339 step=zslongToFix(dmisc3*100);
11283
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 163339 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
163339 if (get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
11284 else if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
11285 {
11286 if (clk2 < 48) clk2+=2;
11287 if (clk2 >= 300) clk2-=2;
11288 }
11289
11290
2/2
✓ Branch 0 taken 18655 times.
✓ Branch 1 taken 144684 times.
163339 if(clk2<32) misc=1;
11291
2/2
✓ Branch 0 taken 9384 times.
✓ Branch 1 taken 135300 times.
144684 else if(clk2<48) misc=2;
11292
2/2
✓ Branch 0 taken 95420 times.
✓ Branch 1 taken 39880 times.
135300 else if(clk2<300)
11293 {
11294 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
11295 {
11296 fix_coords();
11297 }*/
11298 95420 misc=3;
11299 95420 step = zslongToFix(dstep*100);
11300 95420 }
11301
2/2
✓ Branch 0 taken 3366 times.
✓ Branch 1 taken 36514 times.
39880 else if(clk2<316) misc=2;
11302
2/2
✓ Branch 0 taken 17645 times.
✓ Branch 1 taken 18869 times.
36514 else if(clk2<412) misc=1;
11303
2/2
✓ Branch 0 taken 18731 times.
✓ Branch 1 taken 138 times.
18869 else if(clk2<540)
11304 {
11305 18731 misc=0;
11306 18731 step=0;
11307 18731 }
11308 138 else clk2=0;
11309
11310
2/2
✓ Branch 0 taken 162764 times.
✓ Branch 1 taken 575 times.
163339 if(clk2==48) clk=0;
11311
11312 // variable_walk(d->rate, d->homing, 0);
11313 163339 variable_walk(rate, homing, 0);
11314 163339 } // switch(dmisc1)
11315 253529 }
11316
11317 308113 hxofs=(misc>=2)?0:1000;
11318 308113 return enemy::animate(index);
11319 320425 }
11320
11321 13674 bool eLeever::canplace(int32_t d2)
11322 {
11323 13674 int32_t nx=HeroX();
11324 13674 int32_t ny=HeroY();
11325
11326
2/2
✓ Branch 0 taken 2639 times.
✓ Branch 1 taken 11035 times.
13674 if(d2<left) ny&=0xF0;
11327 11035 else nx&=0xF0;
11328
11329
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✓ Branch 2 taken 1336 times.
✓ Branch 3 taken 5503 times.
✓ Branch 4 taken 5532 times.
13674 switch(d2)
11330 {
11331 // case up: ny-=((d->misc1==0)?32:48); break;
11332 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
11333 // case left: nx-=((d->misc1==0)?32:48); break;
11334 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
11335 case up:
11336
2/2
✓ Branch 0 taken 1275 times.
✓ Branch 1 taken 28 times.
1303 ny-=((dmisc1==0||dmisc1==2)?32:48);
11337 1303 break;
11338
11339 case down:
11340
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 1305 times.
1336 ny+=((dmisc1==0||dmisc1==2)?32:48);
11341
11342
4/4
✓ Branch 0 taken 776 times.
✓ Branch 1 taken 560 times.
✓ Branch 2 taken 767 times.
✓ Branch 3 taken 9 times.
1336 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
11343
11344 1336 break;
11345
11346 case left:
11347
2/2
✓ Branch 0 taken 4903 times.
✓ Branch 1 taken 600 times.
5503 nx-=((dmisc1==0||dmisc1==2)?32:48);
11348 5503 break;
11349
11350 case right:
11351
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 4937 times.
5532 nx+=((dmisc1==0||dmisc1==2)?32:48);
11352
11353
4/4
✓ Branch 0 taken 4160 times.
✓ Branch 1 taken 1372 times.
✓ Branch 2 taken 3605 times.
✓ Branch 3 taken 555 times.
5532 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
11354
11355 5532 break;
11356 }
11357
11358
4/4
✓ Branch 0 taken 6088 times.
✓ Branch 1 taken 7586 times.
✓ Branch 2 taken 2565 times.
✓ Branch 3 taken 3523 times.
13674 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
11359 10151 return false;
11360
11361
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 3241 times.
3523 if(d2>=left)
11362
4/4
✓ Branch 0 taken 1071 times.
✓ Branch 1 taken 2170 times.
✓ Branch 2 taken 2849 times.
✓ Branch 3 taken 392 times.
3241 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
11363 2849 return false;
11364
11365 674 x=nx;
11366 674 y=ny;
11367 674 dir=d2^1;
11368 674 return true;
11369 13674 }
11370
11371 321245 void eLeever::draw(BITMAP *dest)
11372 {
11373 // cs=d->cset;
11374 321245 cs=dcset;
11375 321245 update_enemy_frame();
11376
2/4
✓ Branch 0 taken 321245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 321245 times.
321245 if(!fallclk&&!drownclk)
11377 {
11378
2/2
✓ Branch 0 taken 209269 times.
✓ Branch 1 taken 111976 times.
321245 switch(misc)
11379 {
11380 case -1:
11381 case 0:
11382 111976 return;
11383 }
11384 209269 }
11385
11386 209269 enemy::draw(dest);
11387 321245 }
11388
11389 754 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11390 754 {
11391 //zprint2("eWallM::eWallM\n");
11392 377 hashero=false;
11393 //nets+1000;
11394 377 SIZEflags = d->SIZEflags;
11395
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
377 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11396 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11397 // al_trace("Enemy txsz:%i\n", txsz);
11398
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
377 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11399
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
377 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11400
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
377 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11401
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
377 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11402
1/2
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
377 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11403
1/2
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
377 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11404 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11405
1/4
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
377 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11407 {
11408 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11409 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11410 }
11411
11412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
377 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11413 377 }
11414
11415 249384 bool eWallM::animate(int32_t index)
11416 {
11417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249384 times.
249384 if(switch_hooked) return enemy::animate(index);
11418
2/4
✓ Branch 0 taken 249384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249384 times.
249384 if(fallclk||drownclk)
11419 {
11420 return enemy::animate(index);
11421 }
11422
2/2
✓ Branch 0 taken 4788 times.
✓ Branch 1 taken 244596 times.
249384 if(dying)
11423 4788 return Dead(index);
11424
11425
2/2
✓ Branch 0 taken 228902 times.
✓ Branch 1 taken 15694 times.
244596 if(clk==0)
11426 {
11427 15694 removearmos(x,y,ffcactivated);
11428 15694 }
11429
11430 244596 hxofs=1000;
11431
2/2
✓ Branch 0 taken 62103 times.
✓ Branch 1 taken 182493 times.
244596 if(misc==0) //inside wall, ready to spawn?
11432 {
11433 //zprint2("Wallmaster is ready to spawn, clk is: %d\n",clk);
11434 //zprint2("frame is: %d\n",frame);
11435 //zprint2("wallm_load_clk is: %d\n",wallm_load_clk);
11436
4/4
✓ Branch 0 taken 120227 times.
✓ Branch 1 taken 62266 times.
✓ Branch 2 taken 6686 times.
✓ Branch 3 taken 113541 times.
182493 if(frame-wallm_load_clk>80 && clk>=0)
11437 {
11438 //zprint2("getting wall\n");
11439 113541 int32_t wall=hero_on_wall();
11440 //zprint2("Wallmaster wall is %d\n",wall);
11441 113541 int32_t wallm_cnt=0;
11442
11443
2/2
✓ Branch 0 taken 898450 times.
✓ Branch 1 taken 113541 times.
1011991 for(int32_t i=0; i<guys.Count(); i++)
11444
2/2
✓ Branch 0 taken 346283 times.
✓ Branch 1 taken 552167 times.
1450617 if(((enemy*)guys.spr(i))->family==eeWALLM)
11445 {
11446 552167 int32_t m=((enemy*)guys.spr(i))->misc;
11447
11448
4/4
✓ Branch 0 taken 23383 times.
✓ Branch 1 taken 528784 times.
✓ Branch 2 taken 13566 times.
✓ Branch 3 taken 9817 times.
552167 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
11449 {
11450 9817 ++wallm_cnt;
11451 9817 }
11452 552167 }
11453
11454
2/2
✓ Branch 0 taken 113164 times.
✓ Branch 1 taken 377 times.
113541 if(wall>0)
11455 {
11456 377 --wall;
11457 377 misc=1; //emerging from the wall?
11458 //zprint2("Wallmaster is emerging\n");
11459 377 clk2=0;
11460 377 clk3=wall^1;
11461 377 wallm_load_clk=frame;
11462
11463
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 150 times.
377 if(wall<=down)
11464 {
11465
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(HeroDir()==left)
11466 35 dir=right;
11467 else
11468 192 dir=left;
11469 227 }
11470 else
11471 {
11472
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 115 times.
150 if(HeroDir()==up)
11473 35 dir=down;
11474 else
11475 115 dir=up;
11476 }
11477
11478
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 102 times.
✓ Branch 3 taken 103 times.
✓ Branch 4 taken 47 times.
377 switch(wall)
11479 {
11480 case up:
11481 125 y=0;
11482 125 break;
11483
11484 case down:
11485 102 y=160;
11486 102 break;
11487
11488 case left:
11489 103 x=0;
11490 103 break;
11491
11492 case right:
11493 47 x=240;
11494 47 break;
11495 }
11496
11497 //zprint2("Wallmaster (p1) x is %d\n",x);
11498 //zprint2("Wallmaster (p1) y is %d\n",y);
11499
11500
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 192 times.
✓ Branch 4 taken 35 times.
377 switch(dir)
11501 {
11502 case up:
11503 115 y=(HeroY()+48-(wallm_cnt&1)*12);
11504 115 flip=wall&1;
11505 115 break;
11506
11507 case down:
11508 35 y=(HeroY()-48+(wallm_cnt&1)*12);
11509 35 flip=((wall&1)^1)+2;
11510 35 break;
11511
11512 case left:
11513 192 x=(HeroX()+48-(wallm_cnt&1)*12);
11514 192 flip=(wall==up?2:0)+1;
11515 192 break;
11516
11517 case right:
11518 35 x=(HeroX()-48+(wallm_cnt&1)*12);
11519 35 flip=(wall==up?2:0);
11520 35 break;
11521 }
11522
11523 //zprint2("Wallmaster (p2) x is %d\n",x);
11524 //zprint2("Wallmaster (p2) y is %d\n",y);
11525 377 }
11526 113541 }
11527 182493 }
11528 else
11529 62103 wallm_crawl();
11530
11531 244596 return enemy::animate(index);
11532 249384 }
11533
11534 62103 void eWallM::wallm_crawl()
11535 {
11536 62103 bool w=watch;
11537 62103 hxofs=0;
11538
11539
2/2
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 61663 times.
62103 if(slide())
11540 {
11541 440 return;
11542 }
11543
11544 // if(dying || watch || (!hashero && stunclk))
11545
6/8
✓ Branch 0 taken 61663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61374 times.
✓ Branch 3 taken 289 times.
✓ Branch 4 taken 47704 times.
✓ Branch 5 taken 13670 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 47704 times.
61663 if(dying || (!hashero && ( stunclk || frozenclock )))
11546 {
11547 13670 return;
11548 }
11549
11550 47993 watch=false;
11551 47993 ++clk2;
11552 // Misc1: slightly different movement
11553 //zprint2("wallmaster crawl\n");
11554 //zprint2("wallmaster tmpdstep is %d\n",tmpdstep);
11555 47993 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
11556
11557 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
11558 //zprint2("wallmaster crawl tmpmisc is: %d\n", tmpmisc);
11559 //zprint2("wallmaster crawl tmpmisc4 is: %d\n", tmpmisc4);
11560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47993 times.
47993 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
11561 //zprint2("wallmaster crawl misc is: %d\n", misc);
11562
5/6
✓ Branch 0 taken 2791 times.
✓ Branch 1 taken 45202 times.
✓ Branch 2 taken 2140 times.
✓ Branch 3 taken 651 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2140 times.
47993 if(w&&misc>=3&&misc<=5)
11563 {
11564 2140 --clk2;
11565 2140 }
11566
11567
4/4
✓ Branch 0 taken 20291 times.
✓ Branch 1 taken 22042 times.
✓ Branch 2 taken 5567 times.
✓ Branch 3 taken 93 times.
47993 switch(misc)
11568 {
11569 case 1:
11570 case 2:
11571 22042 zc_swap(dir,clk3);
11572 22042 move(step);
11573 22042 zc_swap(dir,clk3);
11574 22042 break;
11575
11576 case 3:
11577 case 4:
11578 case 5:
11579
2/2
✓ Branch 0 taken 2140 times.
✓ Branch 1 taken 18151 times.
20291 if(w)
11580 {
11581 2140 watch=w;
11582 2140 return;
11583 }
11584
11585 18151 move(step);
11586 18151 break;
11587
11588 case 6:
11589 case 7:
11590 5567 zc_swap(dir,clk3);
11591 5567 dir^=1;
11592 5567 move(step);
11593 5567 dir^=1;
11594 5567 zc_swap(dir,clk3);
11595 5567 break;
11596
11597 default:
11598 93 misc=0;
11599 93 break;
11600 }
11601
11602 45853 watch=w;
11603 62103 }
11604
11605 3 void eWallM::grabhero()
11606 {
11607 3 hashero=true;
11608 3 superman=1;
11609 3 }
11610
11611 249671 void eWallM::draw(BITMAP *dest)
11612 {
11613 249671 dummy_bool[1]=hashero;
11614 249671 update_enemy_frame();
11615
11616
4/6
✓ Branch 0 taken 182490 times.
✓ Branch 1 taken 67181 times.
✓ Branch 2 taken 182490 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 182490 times.
249671 if(misc>0 || fallclk||drownclk)
11617 {
11618 67181 masked_draw(dest,16,playing_field_offset+16,224,144);
11619 67181 }
11620
11621 // enemy::draw(dest);
11622 // tile = clk&8 ? 128:129;
11623 249671 }
11624
11625 bool eWallM::isSubmerged() const
11626 {
11627 return ( !misc );
11628 }
11629
11630 1092 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11631 1092 {
11632
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 ox=x; //original x
11633
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 oy=y; //original y
11634
3/4
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 480 times.
546 if(get_bit(quest_rules,qr_TRAPPOSFIX))
11635 {
11636
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
66 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
11637 66 }
11638
11639 546 mainguy=false;
11640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
546 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
11641 //nets+420;
11642 546 dummy_int[1]=0;
11643 546 SIZEflags = d->SIZEflags;
11644
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
546 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11645 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11646 // al_trace("Enemy txsz:%i\n", txsz);
11647
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
546 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11648
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
546 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11649
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
546 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11650
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
546 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11651
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11652
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11653 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11654
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
546 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
546 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11656 {
11657 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11658 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11659 }
11660
11661
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
546 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11662 546 }
11663
11664 399417 bool eTrap::animate(int32_t index)
11665 {
11666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399417 times.
399417 if(switch_hooked) return enemy::animate(index);
11667
2/4
✓ Branch 0 taken 399417 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 399417 times.
399417 if(fallclk||drownclk) return enemy::animate(index);
11668
2/2
✓ Branch 0 taken 391777 times.
✓ Branch 1 taken 7640 times.
399417 if(clk<0)
11669 7640 return enemy::animate(index);
11670
11671
2/2
✓ Branch 0 taken 367022 times.
✓ Branch 1 taken 24755 times.
391777 if(clk==0)
11672 {
11673 24755 removearmos(x,y,ffcactivated);
11674 24755 }
11675
11676
2/2
✓ Branch 0 taken 99581 times.
✓ Branch 1 taken 292196 times.
391777 if(misc==0) // waiting
11677 {
11678 292196 ox = x;
11679 292196 oy = y;
11680 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11681 292196 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11682
11683
4/4
✓ Branch 0 taken 95582 times.
✓ Branch 1 taken 196614 times.
✓ Branch 2 taken 57428 times.
✓ Branch 3 taken 38154 times.
292196 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
11684 {
11685 38154 dir=down;
11686 38154 }
11687
4/4
✓ Branch 0 taken 170626 times.
✓ Branch 1 taken 83416 times.
✓ Branch 2 taken 57428 times.
✓ Branch 3 taken 113198 times.
254042 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
11688 {
11689 113198 dir=right;
11690 113198 }
11691
4/4
✓ Branch 0 taken 88162 times.
✓ Branch 1 taken 52682 times.
✓ Branch 2 taken 57428 times.
✓ Branch 3 taken 30734 times.
140844 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
11692 {
11693 30734 dir=up;
11694 30734 }
11695 else
11696 {
11697 110110 dir=left;
11698 }
11699
11700 292196 int32_t d2=lined_up(15,true);
11701
11702
4/4
✓ Branch 0 taken 100586 times.
✓ Branch 1 taken 191610 times.
✓ Branch 2 taken 539099 times.
✓ Branch 3 taken 246903 times.
475909 if(((d2<left || d2 > right) && (dmisc1==1)) ||
11703
2/2
✓ Branch 0 taken 96443 times.
✓ Branch 1 taken 164472 times.
246903 ((d2>down) && (dmisc1==2)) ||
11704
2/2
✓ Branch 0 taken 90963 times.
✓ Branch 1 taken 86481 times.
164472 ((d2>right) && (!dmisc1)) ||
11705
2/2
✓ Branch 0 taken 183713 times.
✓ Branch 1 taken 38215 times.
177444 ((d2<l_up) && (dmisc1==4)) ||
11706
3/4
✓ Branch 0 taken 183713 times.
✓ Branch 1 taken 145498 times.
✓ Branch 2 taken 183713 times.
✗ Branch 3 not taken.
38215 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
11707
3/4
✓ Branch 0 taken 183713 times.
✓ Branch 1 taken 38215 times.
✓ Branch 2 taken 183713 times.
✗ Branch 3 not taken.
145498 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
11708 {
11709 1186681 d2=-1;
11710 1186681 }
11711
11712
4/4
✓ Branch 0 taken 8772 times.
✓ Branch 1 taken 137926 times.
✓ Branch 2 taken 7990 times.
✓ Branch 3 taken 782 times.
146698 if(d2!=-1 && trapmove(d2))
11713 {
11714 782 dir=d2;
11715 782 misc=1;
11716 782 clk2=(dir==down)?3:0;
11717 782 }
11718 146698 }
11719
11720
2/2
✓ Branch 0 taken 218874 times.
✓ Branch 1 taken 27405 times.
246279 if(misc==1) // charging
11721 {
11722 27405 clk2=(clk2+1)&3;
11723 27405 step=(clk2==3)?1:2;
11724
11725
4/4
✓ Branch 0 taken 27373 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 694 times.
✓ Branch 3 taken 26679 times.
27405 if(!trapmove(dir) || clip())
11726 {
11727 726 misc=2;
11728
11729
1/2
✓ Branch 0 taken 726 times.
✗ Branch 1 not taken.
726 if(dir<l_up)
11730 {
11731 726 dir=dir^1;
11732 726 }
11733 else
11734 {
11735 dir=dir^3;
11736 }
11737 726 }
11738 else
11739 {
11740 26679 sprite::move(step);
11741 }
11742 27405 }
11743
11744
2/2
✓ Branch 0 taken 172595 times.
✓ Branch 1 taken 73684 times.
246279 if(misc==2) // retreating
11745 {
11746 73684 step=(++clk2&1)?1:0;
11747
11748
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 10722 times.
✓ Branch 2 taken 27408 times.
✓ Branch 3 taken 8999 times.
✓ Branch 4 taken 26555 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
73684 switch(dir)
11749 {
11750 case up:
11751
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 10622 times.
10722 if(int32_t(y)<=oy) goto trap_rest;
11752 10622 else sprite::move(step);
11753
11754 10622 break;
11755
11756 case left:
11757
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 27252 times.
27408 if(int32_t(x)<=ox) goto trap_rest;
11758 27252 else sprite::move(step);
11759
11760 27252 break;
11761
11762 case down:
11763
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 8905 times.
8999 if(int32_t(y)>=oy) goto trap_rest;
11764 8905 else sprite::move(step);
11765
11766 8905 break;
11767
11768 case right:
11769
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 26392 times.
26555 if(int32_t(x)>=ox) goto trap_rest;
11770 26392 else sprite::move(step);
11771
11772 26392 break;
11773
11774 case l_up:
11775 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
11776 else sprite::move(step);
11777
11778 break;
11779
11780 case r_up:
11781 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
11782 else sprite::move(step);
11783
11784 break;
11785
11786 case l_down:
11787 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
11788 else sprite::move(step);
11789
11790 break;
11791
11792 case r_down:
11793 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
11794 else sprite::move(step);
11795
11796 break;
11797 trap_rest:
11798 {
11799 513 x=ox;
11800 513 y=oy;
11801 513 misc=0;
11802 }
11803 513 }
11804 73684 }
11805
11806 246279 return enemy::animate(index);
11807 253919 }
11808
11809 36177 bool eTrap::trapmove(int32_t ndir)
11810 {
11811
2/2
✓ Branch 0 taken 21910 times.
✓ Branch 1 taken 14267 times.
36177 if(get_bit(quest_rules,qr_MEANTRAPS))
11812 {
11813
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 20570 times.
21910 if(tmpscr->flags2&fFLOATTRAPS)
11814 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
11815
11816 20570 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
11817 }
11818
11819
6/6
✓ Branch 0 taken 6244 times.
✓ Branch 1 taken 8023 times.
✓ Branch 2 taken 4374 times.
✓ Branch 3 taken 1870 times.
✓ Branch 4 taken 1608 times.
✓ Branch 5 taken 2766 times.
14267 if(oy==80 && !(ndir==left || ndir == right))
11820 2766 return false;
11821
11822
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11501 if(ox==128 && !(ndir==up || ndir==down))
11823 return false;
11824
11825
3/4
✓ Branch 0 taken 4333 times.
✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 4333 times.
✗ Branch 3 not taken.
11501 if(oy<80 && ndir==up)
11826 return false;
11827
11828
3/4
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 3690 times.
✗ Branch 3 not taken.
11501 if(oy>80 && ndir==down)
11829 return false;
11830
11831
4/4
✓ Branch 0 taken 5854 times.
✓ Branch 1 taken 5647 times.
✓ Branch 2 taken 5136 times.
✓ Branch 3 taken 718 times.
11501 if(ox<128 && ndir==left)
11832 718 return false;
11833
11834
4/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 5159 times.
✓ Branch 3 taken 488 times.
10783 if(ox>128 && ndir==right)
11835 488 return false;
11836
11837
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 2207 times.
✓ Branch 3 taken 2929 times.
✓ Branch 4 taken 2207 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy<80 && ndir==l_up)
11838 return false;
11839
11840
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 1809 times.
✓ Branch 3 taken 3327 times.
✓ Branch 4 taken 1809 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy>80 && ndir==l_down)
11841 return false;
11842
11843
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 2126 times.
✓ Branch 3 taken 3033 times.
✓ Branch 4 taken 2126 times.
✗ Branch 5 not taken.
10295 if(ox>128 && oy<80 && ndir==r_up)
11844 return false;
11845
11846
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 1881 times.
✓ Branch 3 taken 3278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1881 times.
10295 if(ox>128 && oy>80 && ndir==r_down)
11847 return false;
11848
11849 10295 return true;
11850 36177 }
11851
11852 27373 bool eTrap::clip()
11853 {
11854
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 26633 times.
27373 if(get_bit(quest_rules,qr_MEANPLACEDTRAPS))
11855 {
11856
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
✓ Branch 2 taken 252 times.
✓ Branch 3 taken 118 times.
✓ Branch 4 taken 118 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
740 switch(dir)
11857 {
11858 case up:
11859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(y<=0) return true;
11860
11861 252 break;
11862
11863 case down:
11864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(y>=160) return true;
11865
11866 252 break;
11867
11868 case left:
11869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if(x<=0) return true;
11870
11871 118 break;
11872
11873 case right:
11874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if(x>=240) return true;
11875
11876 118 break;
11877
11878 case l_up:
11879 if(y<=0||x<=0) return true;
11880
11881 break;
11882
11883 case l_down:
11884 if(y>=160||x<=0) return true;
11885
11886 break;
11887
11888 case r_up:
11889 if(y<=0||x>=240) return true;
11890
11891 break;
11892
11893 case r_down:
11894 if(y>=160||x>=240) return true;
11895
11896 break;
11897 }
11898
11899 740 return false;
11900 }
11901 else
11902 {
11903
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3120 times.
✓ Branch 2 taken 3491 times.
✓ Branch 3 taken 9764 times.
✓ Branch 4 taken 10258 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
26633 switch(dir)
11904 {
11905 case up:
11906
4/4
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 2946 times.
✓ Branch 3 taken 120 times.
3120 if(oy>80 && y<=86) return true;
11907
11908 3000 break;
11909
11910 case down:
11911
4/4
✓ Branch 0 taken 3410 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 3282 times.
✓ Branch 3 taken 128 times.
3491 if(oy<80 && y>=80) return true;
11912
11913 3363 break;
11914
11915 case left:
11916
4/4
✓ Branch 0 taken 9674 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 9455 times.
✓ Branch 3 taken 219 times.
9764 if(ox>128 && x<=124) return true;
11917
11918 9545 break;
11919
11920 case right:
11921
3/4
✓ Branch 0 taken 10258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10031 times.
✓ Branch 3 taken 227 times.
10258 if(ox<120 && x>=116) return true;
11922
11923 10031 break;
11924
11925 case l_up:
11926 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
11927
11928 break;
11929
11930 case l_down:
11931 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
11932
11933 break;
11934
11935 case r_up:
11936 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
11937
11938 break;
11939
11940 case r_down:
11941 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
11942
11943 break;
11944 }
11945
11946 25939 return false;
11947 }
11948 27373 }
11949
11950 399725 void eTrap::draw(BITMAP *dest)
11951 {
11952 399725 update_enemy_frame();
11953 399725 enemy::draw(dest);
11954 399725 }
11955
11956 2279 int32_t eTrap::takehit(weapon*)
11957 {
11958 2279 return 0;
11959 }
11960
11961 238 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11962 238 {
11963 119 lasthit=-1;
11964 119 lasthitclk=0;
11965 119 mainguy=false;
11966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
11967
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 step=2;
11968
3/6
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 71 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
119 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
11969 {
11970
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 dir=(x<=112)?right:left;
11971 48 }
11972 else
11973 {
11974
2/4
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
71 dir=(y<=72)?down:up;
11975 }
11976
11977
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
119 if(get_bit(quest_rules,qr_TRAPPOSFIX))
11978 {
11979 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
11980 }
11981
11982 //nets+((id==eTRAP_LR)?540:520);
11983 119 dummy_int[1]=0;
11984 119 SIZEflags = d->SIZEflags;
11985
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
119 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11986 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11987 // al_trace("Enemy txsz:%i\n", txsz);
11988
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
119 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11989
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11990
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11991
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11992
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11993
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11994 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11995
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11997 {
11998 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11999 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12000 }
12001
12002
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
12003 119 }
12004
12005 66423 bool eTrap2::animate(int32_t index)
12006 {
12007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66423 times.
66423 if(switch_hooked) return enemy::animate(index);
12008
2/4
✓ Branch 0 taken 66423 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66423 times.
66423 if(fallclk||drownclk) return enemy::animate(index);
12009
2/2
✓ Branch 0 taken 64757 times.
✓ Branch 1 taken 1666 times.
66423 if(clk<0)
12010 1666 return enemy::animate(index);
12011
12012
2/2
✓ Branch 0 taken 4108 times.
✓ Branch 1 taken 60649 times.
64757 if(clk==0)
12013 {
12014 4108 removearmos(x,y,ffcactivated);
12015 4108 }
12016
12017
2/2
✓ Branch 0 taken 60365 times.
✓ Branch 1 taken 4392 times.
64757 if(!get_bit(quest_rules,qr_PHANTOMPLACEDTRAPS))
12018 {
12019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4392 times.
4392 if(lasthitclk>0)
12020 {
12021 --lasthitclk;
12022 }
12023 else
12024 {
12025 4392 lasthit=-1;
12026 }
12027
12028 4392 bool hitenemy=false;
12029
12030
2/2
✓ Branch 0 taken 57096 times.
✓ Branch 1 taken 4392 times.
61488 for(int32_t j=0; j<guys.Count(); j++)
12031 {
12032
3/4
✓ Branch 0 taken 52704 times.
✓ Branch 1 taken 4392 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52704 times.
57096 if((j!=index) && (lasthit!=j))
12033 {
12034
1/2
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
52704 if(hit(guys.spr(j)))
12035 {
12036 lasthit=j;
12037 lasthitclk=10;
12038 hitenemy=true;
12039 guys.spr(j)->lasthit=index;
12040 guys.spr(j)->lasthitclk=10;
12041 // guys.spr(j)->dir=guys.spr(j)->dir^1;
12042 }
12043 52704 }
12044 57096 }
12045
12046
4/6
✓ Branch 0 taken 4344 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 4344 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4344 times.
4392 if(!trapmove(dir) || clip() || hitenemy)
12047 {
12048
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(!trapmove(dir) || clip())
12049 {
12050 48 lasthit=-1;
12051 48 lasthitclk=0;
12052 48 }
12053
12054
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(get_bit(quest_rules,qr_MORESOUNDS))
12055 sfx(WAV_ZN1TAP,pan(int32_t(x)));
12056
12057 48 dir=dir^1;
12058 48 }
12059
12060 4392 sprite::move(step);
12061 4392 }
12062 else
12063 {
12064
3/4
✓ Branch 0 taken 58983 times.
✓ Branch 1 taken 1382 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58983 times.
60365 if(!trapmove(dir) || clip())
12065 {
12066
1/2
✓ Branch 0 taken 1382 times.
✗ Branch 1 not taken.
1382 if(get_bit(quest_rules,qr_MORESOUNDS))
12067 sfx(WAV_ZN1TAP,pan(int32_t(x)));
12068
12069 1382 dir=dir^1;
12070 1382 }
12071
12072 60365 sprite::move(step);
12073 }
12074
12075 64757 return enemy::animate(index);
12076 66423 }
12077
12078 64805 bool eTrap2::trapmove(int32_t ndir)
12079 {
12080
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 62927 times.
64805 if(tmpscr->flags2&fFLOATTRAPS)
12081 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
12082
12083 62927 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
12084 64805 }
12085
12086 63327 bool eTrap2::clip()
12087 {
12088
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18583 times.
✓ Branch 2 taken 18827 times.
✓ Branch 3 taken 12915 times.
✓ Branch 4 taken 13002 times.
63327 switch(dir)
12089 {
12090 case up:
12091
1/2
✓ Branch 0 taken 18583 times.
✗ Branch 1 not taken.
18583 if(y<=0) return true;
12092
12093 18583 break;
12094
12095 case down:
12096
1/2
✓ Branch 0 taken 18827 times.
✗ Branch 1 not taken.
18827 if(y>=160) return true;
12097
12098 18827 break;
12099
12100 case left:
12101
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(x<=0) return true;
12102
12103 12915 break;
12104
12105 case right:
12106
1/2
✓ Branch 0 taken 13002 times.
✗ Branch 1 not taken.
13002 if(x>=240) return true;
12107
12108 13002 break;
12109 }
12110
12111 63327 return false;
12112 63327 }
12113
12114 66433 void eTrap2::draw(BITMAP *dest)
12115 {
12116 66433 update_enemy_frame();
12117 66433 enemy::draw(dest);
12118 66433 }
12119
12120 526 int32_t eTrap2::takehit(weapon*)
12121 {
12122 526 return 0;
12123 }
12124
12125 332 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12126 332 {
12127 //do not show "enemy appering" anim -DD
12128 166 clk=0;
12129 166 mainguy=false;
12130 166 clk2=-14;
12131 //Enemy Editor Size Tab
12132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
166 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12133 166 else hxofs = -2;
12134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
166 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12135 166 else hyofs = -2;
12136
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
166 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12137 166 else hxsz = 20;
12138
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
166 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
12139 166 else hysz=20;
12140
12141
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
166 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12142
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
166 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
166 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12144
1/4
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
166 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
12145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
166 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12146 {
12147 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12148 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12149 }
12150
12151
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
166 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
12152 //nets+1640;
12153 166 }
12154
12155 51400 bool eRock::animate(int32_t index)
12156 {
12157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51400 times.
51400 if(switch_hooked) return enemy::animate(index);
12158
2/4
✓ Branch 0 taken 51400 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51400 times.
51400 if(fallclk||drownclk) return enemy::animate(index);
12159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51400 times.
51400 if(dying)
12160 return Dead(index);
12161
12162
2/2
✓ Branch 0 taken 48055 times.
✓ Branch 1 taken 3345 times.
51400 if(clk==0)
12163 {
12164 3345 removearmos(x,y,ffcactivated);
12165 3345 }
12166
12167
2/2
✓ Branch 0 taken 51106 times.
✓ Branch 1 taken 294 times.
51400 if(++clk2==0) // start it
12168 {
12169 294 x=zc_oldrand()&0xF0;
12170 294 y=0;
12171 294 clk3=0;
12172 294 clk2=zc_oldrand()&15;
12173 294 }
12174
12175
2/2
✓ Branch 0 taken 9272 times.
✓ Branch 1 taken 42128 times.
51400 if(clk2>16) // move it
12176 {
12177
2/2
✓ Branch 0 taken 40673 times.
✓ Branch 1 taken 1455 times.
42128 if(clk3<=0) // start bounce
12178 {
12179 1455 dir=zc_oldrand()&1;
12180
12181
2/2
✓ Branch 0 taken 1286 times.
✓ Branch 1 taken 169 times.
1455 if(x<32) dir=1;
12182
12183
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 122 times.
1455 if(x>208) dir=0;
12184 1455 }
12185
12186
2/2
✓ Branch 0 taken 40778 times.
✓ Branch 1 taken 1350 times.
42128 if(clk3<13+16)
12187 {
12188 40778 x += dir ? 1 : -1; //right, left
12189 40778 dummy_int[1]=dir;
12190
12191
2/2
✓ Branch 0 taken 2907 times.
✓ Branch 1 taken 37871 times.
40778 if(clk3<2)
12192 {
12193 2907 y-=2; //up
12194 2907 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12195 2907 }
12196
2/2
✓ Branch 0 taken 4328 times.
✓ Branch 1 taken 33543 times.
37871 else if(clk3<5)
12197 {
12198 4328 y--; //up
12199 4328 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12200 4328 }
12201
2/2
✓ Branch 0 taken 4295 times.
✓ Branch 1 taken 29248 times.
33543 else if(clk3<8)
12202 {
12203 4295 dummy_int[2]=(dummy_int[1]==1)?right:left;
12204 4295 }
12205
2/2
✓ Branch 0 taken 4267 times.
✓ Branch 1 taken 24981 times.
29248 else if(clk3<11)
12206 {
12207 4267 y++; //down
12208 4267 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12209 4267 }
12210 else
12211 {
12212 24981 y+=2; //down
12213 24981 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12214 }
12215
12216 40778 ++clk3;
12217 40778 }
12218
2/2
✓ Branch 0 taken 1175 times.
✓ Branch 1 taken 175 times.
1350 else if(y<176)
12219 1175 clk3=0; // next bounce
12220 else
12221 175 clk2 = -(zc_oldrand()&63); // back to top
12222 42128 }
12223
12224 51400 return enemy::animate(index);
12225 51400 }
12226
12227 14169 void eRock::drawshadow(BITMAP *dest, bool translucent)
12228 {
12229
2/2
✓ Branch 0 taken 1822 times.
✓ Branch 1 taken 12347 times.
14169 if(clk2>=0)
12230 {
12231 12347 int32_t tempy=yofs;
12232 12347 flip = 0;
12233 12347 int32_t fdiv = frate/4;
12234
1/2
✓ Branch 0 taken 12347 times.
✗ Branch 1 not taken.
12347 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
12235
1/2
✓ Branch 0 taken 12347 times.
✗ Branch 1 not taken.
12347 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
12236 12347 efrate:((clk>=(frate>>1))?1:0);
12237 12347 shadowtile = wpnsbuf[spr_shadow].tile+f2;
12238
12239 12347 yofs+=8;
12240
5/6
✓ Branch 0 taken 5808 times.
✓ Branch 1 taken 6539 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12347 times.
✓ Branch 4 taken 5808 times.
✓ Branch 5 taken 6539 times.
12347 yofs+=zc_max(0,zc_min(29-clk3,clk3));
12241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12347 times.
12347 if(!shadow_overpit(this))
12242 12347 enemy::drawshadow(dest, translucent);
12243 12347 yofs=tempy;
12244 12347 }
12245 14169 }
12246
12247 51461 void eRock::draw(BITMAP *dest)
12248 {
12249
4/6
✓ Branch 0 taken 6877 times.
✓ Branch 1 taken 44584 times.
✓ Branch 2 taken 6877 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6877 times.
51461 if(clk2>=0 || fallclk||drownclk)
12250 {
12251 44584 int32_t tempdir=dir;
12252 44584 dir=dummy_int[2];
12253 44584 update_enemy_frame();
12254 44584 enemy::draw(dest);
12255 44584 dir=tempdir;
12256 44584 }
12257 51461 }
12258
12259 600 int32_t eRock::takehit(weapon*)
12260 {
12261 600 return 0;
12262 }
12263
12264 60 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12265 60 {
12266 30 clk=0;
12267 30 mainguy=false;
12268 30 clk2=-14;
12269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12270 30 else hxofs= -10;
12271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12272 30 else hyofs=-10;
12273
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12274 30 else hxsz=36;
12275
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
12276 30 else hysz=36;
12277
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12278 30 else hzsz=16; //can't be jumped
12279
12280
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12281
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12282
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12283
1/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
12284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12285 {
12286 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12287 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12288 }
12289
12290
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
12291 //nets+1680;
12292 30 }
12293
12294 4440 bool eBoulder::animate(int32_t index)
12295 {
12296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
12297
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
12298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
12299 return Dead(index);
12300
12301
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
12302 {
12303 290 removearmos(x,y,ffcactivated);
12304 290 }
12305
12306 zfix *vert;
12307
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & FLAG_USE_FAKE_Z) ? &fakez : get_bit(quest_rules,qr_ENEMIESZAXIS) ? &z : &y;
12308
12309
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
12310 {
12311 32 x=zc_oldrand()&0xF0;
12312 32 y=-32;
12313 32 clk3=0;
12314 32 clk2=zc_oldrand()&15;
12315 32 }
12316
12317
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
12318 {
12319
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
12320 {
12321 131 dir=zc_oldrand()&1;
12322
12323
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
12324
12325
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
12326 131 }
12327
12328
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
12329 {
12330 3487 x += dir ? 1 : -1; //right, left
12331 3487 dummy_int[1]=dir;
12332
12333
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
12334 {
12335 261 y-=2; //up
12336 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12337 261 }
12338
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
12339 {
12340 382 y--; //up
12341 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12342 382 }
12343
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
12344 {
12345 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
12346 376 }
12347
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
12348 {
12349 367 y++; //down
12350 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12351 367 }
12352 else
12353 {
12354 2101 y+=2; //down
12355 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12356 }
12357
12358 3487 ++clk3;
12359 3487 }
12360
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
12361 101 clk3=0; // next bounce
12362 else
12363 10 clk2 = -(zc_oldrand()&63); // back to top
12364 3598 }
12365
12366 4440 return enemy::animate(index);
12367 4440 }
12368
12369 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
12370 {
12371
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
12372 {
12373 3868 int32_t tempy=yofs;
12374 3868 flip = 0;
12375 3868 int32_t f2=((clk<<2)/frate)<<1;
12376 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
12377
5/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3868 times.
✓ Branch 4 taken 1729 times.
✓ Branch 5 taken 2139 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
12378
12379 3868 yofs+=8;
12380 3868 xofs-=8;
12381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12382 3868 enemy::drawshadow(dest, translucent);
12383 3868 xofs+=16;
12384 3868 ++shadowtile;
12385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12386 3868 enemy::drawshadow(dest, translucent);
12387 3868 yofs+=16;
12388 3868 shadowtile+=20;
12389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12390 3868 enemy::drawshadow(dest, translucent);
12391 3868 xofs-=16;
12392 3868 --shadowtile;
12393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12394 3868 enemy::drawshadow(dest, translucent);
12395 3868 xofs+=8;
12396 3868 yofs=tempy;
12397 3868 }
12398 4440 }
12399
12400 4440 void eBoulder::draw(BITMAP *dest)
12401 {
12402
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
12403 {
12404 3868 int32_t tempdir=dir;
12405 3868 dir=dummy_int[2];
12406 3868 update_enemy_frame();
12407 3868 dir=tempdir;
12408 3868 xofs-=8;
12409 3868 yofs-=8;
12410 3868 drawblock(dest,15);
12411 3868 xofs+=8;
12412 3868 yofs+=8;
12413 // enemy::draw(dest);
12414 3868 }
12415 4440 }
12416
12417 int32_t eBoulder::takehit(weapon*)
12418 {
12419 return 0;
12420 }
12421
12422 4038 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
12423
3/4
✓ Branch 0 taken 2019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 514 times.
✓ Branch 3 taken 1505 times.
2019 minRange(get_bit(quest_rules, qr_BROKENSTATUES) ? 0 : Clk)
12424 4038 {
12425 /* fixing
12426 hp=1;
12427 */
12428 2019 mainguy=false;
12429
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2012 times.
2019 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12430 2019 hclk=clk; // the "no fire" range
12431 2019 clk=0;
12432 2019 clk3=96;
12433 2019 timer=0;
12434
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2012 times.
2019 if(o_tile==0)
12435 {
12436 2012 superman=1;
12437 2012 hxofs=1000;
12438 2012 }
12439 2019 SIZEflags = d->SIZEflags;
12440
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2019 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12441 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12442 // al_trace("Enemy txsz:%i\n", txsz);
12443
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2019 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12444
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2019 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12445
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2019 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12446
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2019 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12447
1/2
✓ Branch 0 taken 2019 times.
✗ Branch 1 not taken.
2019 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12448
1/2
✓ Branch 0 taken 2019 times.
✗ Branch 1 not taken.
2019 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12449 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12450
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2019 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
2019 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12452 {
12453 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12454 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12455 }
12456
12457
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2019 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12458 2019 }
12459
12460 1424319 bool eProjectile::animate(int32_t index)
12461 {
12462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1424319 times.
1424319 if(switch_hooked) return enemy::animate(index);
12463
2/4
✓ Branch 0 taken 1424319 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1424319 times.
1424319 if(fallclk||drownclk) return enemy::animate(index);
12464
2/2
✓ Branch 0 taken 1417470 times.
✓ Branch 1 taken 6849 times.
1424319 if(clk==0)
12465 {
12466 6849 removearmos(x,y,ffcactivated);
12467 6849 }
12468
12469 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12470 1424319 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12471
12472
4/4
✓ Branch 0 taken 471406 times.
✓ Branch 1 taken 952913 times.
✓ Branch 2 taken 257448 times.
✓ Branch 3 taken 213958 times.
1424319 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
12473 {
12474 213958 dir=down;
12475 213958 }
12476
4/4
✓ Branch 0 taken 777159 times.
✓ Branch 1 taken 433202 times.
✓ Branch 2 taken 257448 times.
✓ Branch 3 taken 519711 times.
1210361 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
12477 {
12478 519711 dir=right;
12479 519711 }
12480
4/4
✓ Branch 0 taken 482013 times.
✓ Branch 1 taken 208637 times.
✓ Branch 2 taken 257448 times.
✓ Branch 3 taken 224565 times.
690650 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
12481 {
12482 224565 dir=up;
12483 224565 }
12484 else
12485 {
12486 466085 dir=left;
12487 }
12488
12489
3/4
✓ Branch 0 taken 1424319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 741539 times.
✓ Branch 3 taken 682780 times.
1424319 if(!stunclk && ++clk3>80)
12490 {
12491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 682780 times.
682780 if(dmisc1==9) // Breath type
12492 {
12493 if(timer==0)
12494 {
12495 unsigned r=zc_oldrand();
12496
12497 if(!(r&63))
12498 {
12499 timer=zc_oldrand()%50+50;
12500 }
12501 }
12502
12503 if(timer>0)
12504 {
12505 if(timer%4==0)
12506 {
12507 FireBreath(false);
12508 }
12509
12510 if(--timer==0)
12511 {
12512 clk3=0;
12513 }
12514 }
12515 }
12516
12517 else // Not breath type
12518 {
12519 682780 unsigned r=zc_oldrand();
12520
12521
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 672154 times.
✓ Branch 2 taken 810 times.
✓ Branch 3 taken 9816 times.
682780 if(!(r&63) && !HeroInRange(minRange))
12522 {
12523 9816 FireWeapon();
12524
12525
3/4
✓ Branch 0 taken 7445 times.
✓ Branch 1 taken 2371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52 times.
9868 if(get_bit(quest_rules, qr_BROKENSTATUES)==0 &&
12526
3/4
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 7393 times.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
7445 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
12527 {
12528
2/2
✓ Branch 0 taken 7023 times.
✓ Branch 1 taken 422 times.
7445 if(!((r>>7)&15))
12529 {
12530 422 x-=4;
12531 422 FireWeapon();
12532 422 x+=4;
12533 422 }
12534 7445 }
12535
12536 9816 clk3=0;
12537 9816 }
12538 }
12539 682780 }
12540
12541 1424319 return enemy::animate(index);
12542 1424319 }
12543
12544 1429636 void eProjectile::draw(BITMAP *dest)
12545 {
12546 1429636 update_enemy_frame();
12547 1429636 enemy::draw(dest);
12548 1429636 }
12549
12550 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12551 {
12552 hxofs=1000;
12553 }
12554
12555 void eTrigger::draw(BITMAP *dest)
12556 {
12557 update_enemy_frame();
12558 enemy::draw(dest);
12559 }
12560
12561 void eTrigger::death_sfx()
12562 {
12563 //silent death
12564 }
12565
12566 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12567 {
12568 o_tile+=wpnsbuf[iwNPCs].tile;
12569 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12570 SIZEflags = d->SIZEflags;
12571 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12572 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12573 // al_trace("Enemy txsz:%i\n", txsz);
12574 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12575 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12576 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12577 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12578 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12579 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12580 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12581 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12582 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12583 {
12584 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12585 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12586 }
12587
12588 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12589 }
12590
12591 bool eNPC::animate(int32_t index)
12592 {
12593 if(switch_hooked) return enemy::animate(index);
12594 if(dying)
12595 return Dead(index);
12596
12597 if(clk==0)
12598 {
12599 removearmos(x,y,ffcactivated);
12600 }
12601
12602 switch(dmisc2)
12603 {
12604 case 0:
12605 {
12606 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12607 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12608
12609 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
12610 {
12611 dir=down;
12612 }
12613
12614 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
12615 {
12616 dir=right;
12617 }
12618 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
12619 {
12620 dir=up;
12621 }
12622 else
12623 {
12624 dir=left;
12625 }
12626 }
12627 break;
12628
12629 case 1:
12630 halting_walk(rate, homing, 0, hrate, 48);
12631
12632 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
12633 {
12634 newdir(rate, homing, 0);
12635 clk2=48;
12636 ++misc;
12637 }
12638
12639 if(clk2==0)
12640 misc=0;
12641
12642 break;
12643 }
12644
12645 return enemy::animate(index);
12646 }
12647
12648 void eNPC::draw(BITMAP *dest)
12649 {
12650 update_enemy_frame();
12651 enemy::draw(dest);
12652 }
12653
12654 int32_t eNPC::takehit(weapon*)
12655 {
12656 return 0;
12657 }
12658
12659 188 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12660 188 {
12661
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
12662 {
12663 94 o_tile=clk;
12664 94 cs=id>>12;
12665 94 }
12666
12667 94 id=id&0xFFF;
12668 94 clk=0;
12669
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
12670 94 mainguy=false;
12671 94 SIZEflags = d->SIZEflags;
12672
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12673 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12674 // al_trace("Enemy txsz:%i\n", txsz);
12675
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12676
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12677
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12678
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12679
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12680
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12681 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12682
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12684 {
12685 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12686 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12687 }
12688
12689
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12690 94 }
12691
12692 81 void eSpinTile::facehero()
12693 {
12694
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
12695 {
12696
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
12697 1 dir = up;
12698 else
12699 dir = down;
12700 1 }
12701 else
12702 {
12703 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12704 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12705
12706
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
12707 {
12708 12 dir=l_down;
12709 12 }
12710
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
12711 {
12712 1 dir=down;
12713 1 }
12714
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
12715 {
12716 12 dir=r_down;
12717 12 }
12718
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
12719 {
12720 6 dir=right;
12721 6 }
12722
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
12723 {
12724 17 dir=r_up;
12725 17 }
12726
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
12727 {
12728 8 dir=up;
12729 8 }
12730
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
12731 {
12732 6 dir=l_up;
12733 6 }
12734 else
12735 {
12736 18 dir=left;
12737 }
12738 }
12739 81 }
12740
12741
12742 15539 bool eSpinTile::animate(int32_t index)
12743 {
12744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
12745
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
12746
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
12747 {
12748 1152 return Dead(index);
12749 }
12750
12751
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
12752 {
12753 1241 removearmos(x,y,ffcactivated);
12754 1241 }
12755
12756 14387 ++misc;
12757
12758
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
12759 {
12760 81 facehero();
12761 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12762 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
12763 81 angular=true;
12764 81 angle=ddir;
12765 81 step=zslongToFix(dstep*100);
12766 81 }
12767
12768
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
12769 52 kickbucket();
12770
12771 14387 sprite::move(step);
12772 14387 return enemy::animate(index);
12773 15539 }
12774
12775 15457 void eSpinTile::draw(BITMAP *dest)
12776 {
12777 15457 update_enemy_frame();
12778 15457 y-=(misc>>4);
12779 15457 yofs+=2;
12780 15457 enemy::draw(dest);
12781 15457 yofs-=2;
12782 15457 y+=(misc>>4);
12783 15457 }
12784
12785 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
12786 {
12787 15457 flip = 0;
12788 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
12789 15457 yofs+=4;
12790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
12791 15457 enemy::drawshadow(dest, translucent);
12792 15457 yofs-=4;
12793 15457 }
12794
12795 2742 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
12796 2742 {
12797 //these are here to bypass compiler warnings about unused arguments
12798 1371 Clk=Clk;
12799 1371 mainguy=false;
12800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
1371 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12801 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
12802 {
12803 clk=1;
12804 }*/
12805 //nets+880;
12806 1371 SIZEflags = d->SIZEflags;
12807
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1371 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12808 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12809 // al_trace("Enemy txsz:%i\n", txsz);
12810
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1371 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12811
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1371 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12812
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1371 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12813
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1371 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12814
1/2
✓ Branch 0 taken 1371 times.
✗ Branch 1 not taken.
1371 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12815
1/2
✓ Branch 0 taken 1371 times.
✗ Branch 1 not taken.
1371 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12816 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12817
1/4
✓ Branch 0 taken 1371 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1371 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
1371 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12819 {
12820 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12821 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12822 }
12823
12824
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1371 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12825 1371 }
12826
12827 370007 void eZora::facehero()
12828 {
12829
2/2
✓ Branch 0 taken 6197 times.
✓ Branch 1 taken 363810 times.
370007 if(Hero.x-x==0)
12830 {
12831 6197 dir=(Hero.y+8<y)?up:down;
12832 6197 }
12833 else
12834 {
12835 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12836 363810 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12837
12838
4/4
✓ Branch 0 taken 76040 times.
✓ Branch 1 taken 287770 times.
✓ Branch 2 taken 28717 times.
✓ Branch 3 taken 47323 times.
363810 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
12839 {
12840 47323 dir=l_down;
12841 47323 }
12842
4/4
✓ Branch 0 taken 54130 times.
✓ Branch 1 taken 262357 times.
✓ Branch 2 taken 28717 times.
✓ Branch 3 taken 25413 times.
316487 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
12843 {
12844 25413 dir=down;
12845 25413 }
12846
4/4
✓ Branch 0 taken 73430 times.
✓ Branch 1 taken 217644 times.
✓ Branch 2 taken 28717 times.
✓ Branch 3 taken 44713 times.
291074 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
12847 {
12848 44713 dir=r_down;
12849 44713 }
12850
4/4
✓ Branch 0 taken 98067 times.
✓ Branch 1 taken 148294 times.
✓ Branch 2 taken 28717 times.
✓ Branch 3 taken 69350 times.
246361 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
12851 {
12852 69350 dir=right;
12853 69350 }
12854
4/4
✓ Branch 0 taken 78233 times.
✓ Branch 1 taken 98778 times.
✓ Branch 2 taken 28717 times.
✓ Branch 3 taken 49516 times.
177011 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
12855 {
12856 49516 dir=r_up;
12857 49516 }
12858
4/4
✓ Branch 0 taken 51593 times.
✓ Branch 1 taken 75902 times.
✓ Branch 2 taken 28717 times.
✓ Branch 3 taken 22876 times.
127495 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
12859 {
12860 22876 dir=up;
12861 22876 }
12862
4/4
✓ Branch 0 taken 71275 times.
✓ Branch 1 taken 33344 times.
✓ Branch 2 taken 42558 times.
✓ Branch 3 taken 28717 times.
104619 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
12863 {
12864 42558 dir=l_up;
12865 42558 }
12866 else
12867 {
12868 62061 dir=left;
12869 }
12870 }
12871 370007 }
12872
12873 487876 bool eZora::animate(int32_t index)
12874 {
12875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 487876 times.
487876 if(switch_hooked) return enemy::animate(index);
12876
2/2
✓ Branch 0 taken 1836 times.
✓ Branch 1 taken 486040 times.
487876 if(dying)
12877 1836 return Dead(index);
12878
12879
2/2
✓ Branch 0 taken 482891 times.
✓ Branch 1 taken 3149 times.
486040 if(clk==0)
12880 {
12881 3149 removearmos(x,y,ffcactivated);
12882 3149 }
12883
12884
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 486009 times.
486040 if(watch)
12885 {
12886 31 ++clock_zoras[id];
12887 31 return true;
12888 }
12889
12890
2/2
✓ Branch 0 taken 116002 times.
✓ Branch 1 taken 370007 times.
486009 if(get_bit(quest_rules,qr_NEWENEMYTILES))
12891 {
12892 370007 facehero();
12893 370007 }
12894
12895
6/6
✓ Branch 0 taken 2922 times.
✓ Branch 1 taken 2816 times.
✓ Branch 2 taken 2359 times.
✓ Branch 3 taken 472362 times.
✓ Branch 4 taken 3763 times.
✓ Branch 5 taken 1787 times.
486009 switch(clk)
12896 {
12897 case 0: // reposition him
12898 {
12899 3763 int32_t t=0;
12900 3763 int32_t pos2=zc_oldrand()%160 + 16;
12901 3763 bool placed=false;
12902
12903
4/4
✓ Branch 0 taken 3740 times.
✓ Branch 1 taken 18779 times.
✓ Branch 2 taken 11890 times.
✓ Branch 3 taken 3149 times.
22519 while(!placed && t<160)
12904 {
12905 11890 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
12906
5/6
✓ Branch 0 taken 3828 times.
✓ Branch 1 taken 8062 times.
✓ Branch 2 taken 3828 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 307 times.
✓ Branch 5 taken 3126 times.
15323 if(watertype && ((editorflags & ENEMY_FLAG6) ||
12907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3828 times.
3828 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
12908
3/4
✓ Branch 0 taken 3828 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3433 times.
✓ Branch 3 taken 3433 times.
3828 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
12909 {
12910 3126 x=(pos2&15)<<4;
12911 3126 y=pos2&0xF0;
12912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3126 times.
3126 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
12913 3126 hxofs=1000; // avoid hit detection
12914 3126 stunclk=0;
12915 3126 placed=true;
12916 3126 }
12917
12918 18756 pos2+=19;
12919
12920
2/2
✓ Branch 0 taken 16549 times.
✓ Branch 1 taken 2207 times.
18756 if(pos2>=176)
12921 2207 pos2-=160;
12922
12923 18756 ++t;
12924 }
12925
12926
3/4
✓ Branch 0 taken 3126 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3126 times.
3149 if(!placed || whistleclk>=88) // can't place him, he's gone
12927 23 return true;
12928
12929 }
12930 3126 break;
12931
12932 case 35:
12933
2/2
✓ Branch 0 taken 2232 times.
✓ Branch 1 taken 690 times.
2922 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
12934 {
12935 690 dir=(Hero.y+8<y)?up:down;
12936 690 }
12937
12938 2922 hxofs=0;
12939 2922 break;
12940
12941 case 35+19:
12942 2816 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
12943 2816 sfx(wpnsfx(wpn),pan(int32_t(x)));
12944 2816 break;
12945
12946 case 35+66:
12947 2359 hxofs=1000;
12948 2359 break;
12949
12950 case 198:
12951 1787 clk=-1;
12952 1787 break;
12953 }
12954
12955 485372 return enemy::animate(index);
12956 487262 }
12957
12958 487649 void eZora::draw(BITMAP *dest)
12959 {
12960
2/2
✓ Branch 0 taken 9385 times.
✓ Branch 1 taken 478264 times.
487649 if(clk<3)
12961 9385 return;
12962
12963 478264 update_enemy_frame();
12964 478264 enemy::draw(dest);
12965 487649 }
12966
12967 bool eZora::isSubmerged() const
12968 {
12969 return ( clk < 3 );
12970 }
12971
12972
4/8
✓ Branch 0 taken 16957 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16957 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16957 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16957 times.
✗ Branch 7 not taken.
50871 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12973 33914 {
12974 16957 multishot= timer = fired = dashing = 0;
12975 16957 hashero = false;
12976 16957 dummy_bool[0]=false;
12977 16957 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
12978
5/6
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 16840 times.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✓ Branch 5 taken 50 times.
16957 if(dmisc9==e9tARMOS && zc_oldrand()&1)
12979 {
12980
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
67 step=zslongToFix(dmisc10*100);
12981
12982
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 60 times.
67 if(anim==aARMOS4) o_tile+=20;
12983 67 }
12984
12985
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 16840 times.
16957 if(flags & guy_fadeflicker)
12986 {
12987 117 clk=0;
12988 117 superman = 1;
12989 117 fading=fade_flicker;
12990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12991 117 dir=down;
12992
12993
4/6
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 65 times.
117 if(!canmove(down,(zfix)8,spw_none,false))
12994
3/6
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52 times.
✗ Branch 5 not taken.
52 clk3=int32_t(13.0/step);
12995 117 }
12996
1/2
✓ Branch 0 taken 16840 times.
✗ Branch 1 not taken.
16840 else if(flags & guy_fadeinstant)
12997 {
12998 clk=0;
12999 }
13000
13001
1/2
✓ Branch 0 taken 16957 times.
✗ Branch 1 not taken.
16957 shadowdistance = 0;
13002 16957 clk4 = clk5 = 0;
13003 //nets+2380;
13004 16957 SIZEflags = d->SIZEflags;
13005
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16957 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13006 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13007 // al_trace("Enemy txsz:%i\n", txsz);
13008
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16957 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13009
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16957 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
13010
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16957 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
13011
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16957 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13012
1/2
✓ Branch 0 taken 16957 times.
✗ Branch 1 not taken.
16957 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13013
1/2
✓ Branch 0 taken 16957 times.
✗ Branch 1 not taken.
16957 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13014 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13015
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16957 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
16957 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13017 {
13018 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13019 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13020 }
13021
13022
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16957 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13023 16957 }
13024
13025 7027045 bool eStalfos::animate(int32_t index)
13026 {
13027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7027045 times.
7027045 if(switch_hooked) return enemy::animate(index);
13028
3/4
✓ Branch 0 taken 7026903 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7026903 times.
7027045 if(fallclk||drownclk)
13029 {
13030 142 return enemy::animate(index);
13031 }
13032
2/2
✓ Branch 0 taken 156550 times.
✓ Branch 1 taken 6870353 times.
7026903 if(dying)
13033 {
13034
2/2
✓ Branch 0 taken 156522 times.
✓ Branch 1 taken 28 times.
156550 if(hashero)
13035 {
13036 28 Hero.setEaten(0);
13037 28 hashero=false;
13038 28 }
13039
13040
10/14
✓ Branch 0 taken 14564 times.
✓ Branch 1 taken 141986 times.
✓ Branch 2 taken 1140 times.
✓ Branch 3 taken 13424 times.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 1091 times.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 49 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 49 times.
156550 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
13041 {
13042 49 hp=-1000;
13043
5/10
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
49 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
13044 49 Ewpns.add(ew);
13045 49 ew->fakez = fakez;
13046
13047
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
49 if(wpn==ewSBomb || wpn==ewBomb)
13048 {
13049 49 ew->step=0;
13050 49 ew->id=wpn;
13051 49 ew->misc=50;
13052 49 ew->clk=48;
13053 49 }
13054
13055 49 fired=true;
13056 49 }
13057
6/6
✓ Branch 0 taken 74530 times.
✓ Branch 1 taken 81971 times.
✓ Branch 2 taken 61392 times.
✓ Branch 3 taken 13138 times.
✓ Branch 4 taken 61374 times.
✓ Branch 5 taken 18 times.
156501 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
13058 {
13059
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
13060 {
13061 1 int32_t wpn2 = wpn+dmisc3;
13062
13063
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
13064 {
13065 wpn2=wpn;
13066 }
13067
13068 1 dummy_bool[0]=true;
13069 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
13070 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13071 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
13072 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13073 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
13074 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13075 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
13076 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13077 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
13078 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13079 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
13080 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13081 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
13082 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13083 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
13084 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13085 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
13086 1 }
13087 18 }
13088
13089 156550 KillWeapon();
13090 156550 return Dead(index);
13091 }
13092 //vire split
13093 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
13094 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
13095
13/14
✓ Branch 0 taken 8833 times.
✓ Branch 1 taken 6861520 times.
✓ Branch 2 taken 8833 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 8684 times.
✓ Branch 6 taken 660353 times.
✓ Branch 7 taken 6209851 times.
✓ Branch 8 taken 659185 times.
✓ Branch 9 taken 1168 times.
✓ Branch 10 taken 3212 times.
✓ Branch 11 taken 655973 times.
✓ Branch 12 taken 591 times.
✓ Branch 13 taken 2621 times.
6870353 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
13096 {
13097 740 stop_bgsfx(index);
13098 740 int32_t kids = guys.Count();
13099 740 int32_t id2=dmisc3;
13100
2/2
✓ Branch 0 taken 1466 times.
✓ Branch 1 taken 740 times.
2206 for(int32_t i=0; i < dmisc4; i++)
13101 {
13102 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
13103
4/6
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 1124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1124 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1466 times.
1466 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
13104 1466 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13105 1466 }
13106
13107
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(itemguy) // Hand down the carried item
13108 {
13109 guycarryingitem = guys.Count()-1;
13110 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13111 itemguy = false;
13112 }
13113
13114
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(hashero)
13115 {
13116 Hero.setEaten(0);
13117 hashero=false;
13118 }
13119
13120
4/4
✓ Branch 0 taken 726 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 591 times.
✓ Branch 3 taken 135 times.
740 if(deadsfx > 0 && dmisc2==e2tSPLIT)
13121 135 sfx(deadsfx,pan(int32_t(x)));
13122
13123 740 return true;
13124 }
13125 /*
13126 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
13127 {
13128 stop_bgsfx(index);
13129 int32_t kids = guys.Count();
13130 int32_t id2=dmisc3;
13131
13132 for(int32_t i=0; i < dmisc4; i++)
13133 {
13134 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
13135 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
13136 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13137 }
13138
13139 if(itemguy) // Hand down the carried item
13140 {
13141 guycarryingitem = guys.Count()-1;
13142 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13143 itemguy = false;
13144 }
13145
13146 if(hashero)
13147 {
13148 Hero.setEaten(0);
13149 hashero=false;
13150 }
13151
13152 return true;
13153 }
13154 */
13155
2/2
✓ Branch 0 taken 7805 times.
✓ Branch 1 taken 6861808 times.
6869613 if(fading)
13156 {
13157
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 7661 times.
7805 if(++clk4 > 60)
13158 {
13159 144 clk4=0;
13160 144 superman=0;
13161 144 fading=0;
13162
13163
4/6
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 117 times.
144 if(flags2&cmbflag_armos && z==0 && fakez == 0)
13164 {
13165 //if a custom size (not 16px by 16px)
13166
13167 //if a custom size (not 16px by 16px)
13168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if (ffcactivated)
13169 removearmosffc(ffcactivated-1);
13170 else
13171 {
13172
4/8
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 117 times.
117 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
13173 {
13174 //zprint("spawn big enemy from armos\n");
13175 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
13176 for(int32_t dx = 0; dx < tysz; dx ++)
13177 {
13178 for(int32_t dy = 0; dy < tysz; dy++)
13179 {
13180 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
13181 did_armos = false;
13182 }
13183 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
13184 did_armos = false;
13185 }
13186 for(int32_t dy = 0; dy < tysz; dy ++)
13187 {
13188 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
13189 did_armos = false;
13190 }
13191 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
13192 }
13193 117 else removearmos(x,y);
13194 }
13195 /*
13196 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
13197 {
13198 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
13199 for(int32_t dx = 0; dx < hxsz; dx += 16)
13200 {
13201 for(int32_t dy = 0; dy < hysz; dy += 16)
13202 {
13203 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
13204 did_armos = false;
13205 }
13206 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
13207 did_armos = false;
13208 }
13209 for(int32_t dy = 0; dy < hysz; dy += 16)
13210 {
13211 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
13212 did_armos = false;
13213 }
13214 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
13215 }
13216 else removearmos(x,y,ffcactivated);
13217 */
13218
13219 117 }
13220
13221 144 clk2=0;
13222
13223 144 newdir();
13224 144 }
13225 7661 else return enemy::animate(index);
13226 144 }
13227
6/8
✓ Branch 0 taken 29439 times.
✓ Branch 1 taken 6832369 times.
✓ Branch 2 taken 29439 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29439 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27572 times.
✓ Branch 7 taken 1867 times.
6861808 else if(flags2&cmbflag_armos && z==0 && fakez == 0 && clk==0)
13228 1867 removearmos(x,y,ffcactivated);
13229
13230
13231
2/2
✓ Branch 0 taken 2221 times.
✓ Branch 1 taken 6859731 times.
6861952 if(hashero)
13232 {
13233 2221 Hero.setX(x);
13234 2221 Hero.setY(y);
13235 2221 ++clk2;
13236
13237
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 2171 times.
✓ Branch 3 taken 50 times.
2221 if(clk2==(dmisc8==0 ? 95 : dmisc8))
13238 {
13239
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 switch(dmisc7)
13240 {
13241 case e7tEATITEMS:
13242 {
13243 for(int32_t i=0; i<MAXITEMS; i++)
13244 {
13245 if(itemsbuf[i].flags&ITEM_EDIBLE)
13246 game->set_item(i, false);
13247 }
13248
13249 break;
13250 }
13251
13252 case e7tEATMAGIC:
13253 game->change_dmagic(-1*game->get_magicdrainrate());
13254 break;
13255
13256 case e7tEATRUPEES:
13257 game->change_drupy(-1);
13258 break;
13259 }
13260
13261 50 clk2=0;
13262 50 }
13263
13264
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 2052 times.
2221 if((clk&0x18)==8) // stop its animation on the middle frame
13265 2052 --clk;
13266 2221 }
13267
4/4
✓ Branch 0 taken 438916 times.
✓ Branch 1 taken 6420815 times.
✓ Branch 2 taken 251749 times.
✓ Branch 3 taken 187167 times.
6859731 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
13268 {
13269 // Movement engine
13270
4/6
✓ Branch 0 taken 331274 times.
✓ Branch 1 taken 6341290 times.
✓ Branch 2 taken 2047 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6339243 times.
✗ Branch 5 not taken.
6672564 if(clk>=0) switch(id>>12)
13271 {
13272 case 0: // Normal movement
13273
13274 /*
13275 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
13276 {
13277 // Overloading clk4 (Tribble clock) here...
13278 step=17/100.0;
13279 if(clk4<32) misc=1;
13280 else if(clk4<48) misc=2;
13281 else if(clk4<300) { misc=3; step = dstep/100.0; }
13282 else if(clk4<316) misc=2;
13283 else if(clk4<412) misc=1;
13284 else if(clk4<540) { misc=0; step=0; }
13285 else clk4=0;
13286 if(clk4==48) clk=0;
13287 hxofs=(misc>=2)?0:1000;
13288 if (dmisc9==e9tLEEVER)
13289 variable_walk(rate, homing, 0);
13290 else
13291 variable_walk_8(rate, homing, 4, 0);
13292 break;
13293 }
13294 */
13295
4/4
✓ Branch 0 taken 6199224 times.
✓ Branch 1 taken 140019 times.
✓ Branch 2 taken 216564 times.
✓ Branch 3 taken 5982660 times.
6339243 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
13296 {
13297 356583 vire_hop();
13298 356583 break;
13299 }
13300
2/2
✓ Branch 0 taken 454101 times.
✓ Branch 1 taken 5528559 times.
5982660 else if(dmisc9==e9tROPE) //Rope charge
13301 {
13302
9/10
✓ Branch 0 taken 436679 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 67093 times.
✓ Branch 3 taken 369586 times.
✓ Branch 4 taken 61231 times.
✓ Branch 5 taken 5862 times.
✓ Branch 6 taken 60515 times.
✓ Branch 7 taken 716 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 60515 times.
454101 if(!fired && dashing && !stunclk && !watch && !frozenclock)
13303 {
13304
5/6
✓ Branch 0 taken 2372 times.
✓ Branch 1 taken 58143 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2357 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
60515 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
13305 {
13306
13307
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if ( get_bit(quest_rules,qr_BOMBCHUSUPERBOMB) )
13308 {
13309 14 hp=-1000;
13310
13311
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
13312 {
13313
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
13314 14 Ewpns.add(ew);
13315 14 ew->fakez = fakez;
13316
13317
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
13318 {
13319 14 ew->step=0;
13320 14 ew->id=wpn+dmisc3;
13321 14 ew->misc=50;
13322 14 ew->clk=48;
13323 14 }
13324
13325 14 fired=true;
13326 14 }
13327 else
13328 {
13329 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
13330 Ewpns.add(ew);
13331 ew->fakez = fakez;
13332
13333 if(wpn==ewSBomb || wpn==ewBomb)
13334 {
13335 ew->step=0;
13336 ew->id=wpn;
13337 ew->misc=50;
13338 ew->clk=48;
13339 }
13340
13341 fired=true;
13342 }
13343 14 }
13344
13345 else
13346 {
13347 1 hp=-1000;
13348
13349 int32_t wpn2;
13350
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
13351 1 wpn2=wpn;
13352 else
13353 wpn2=wpn;
13354
13355
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
13356 1 Ewpns.add(ew);
13357 1 ew->fakez = fakez;
13358
13359
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(wpn2==ewSBomb || wpn2==ewBomb)
13360 {
13361 1 ew->step=0;
13362 1 ew->id=wpn2;
13363 1 ew->misc=50;
13364 1 ew->clk=48;
13365 1 }
13366
13367 1 fired=true;
13368 }
13369 15 }
13370 60515 }
13371
13372 454101 charge_attack();
13373 454101 break;
13374 }
13375 /*
13376 * Boomerang-throwers have a halt count of 1
13377 * Zols have a halt count of (zc_oldrand()&7)<<4
13378 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
13379 * Everything else has 48
13380 */
13381 else
13382 {
13383
2/2
✓ Branch 0 taken 236388 times.
✓ Branch 1 taken 5292171 times.
5528559 if(wpn==ewBrang) // Goriya
13384 {
13385 236388 halting_walk(rate,homing,0,hrate, 1);
13386 236388 }
13387
4/4
✓ Branch 0 taken 5262615 times.
✓ Branch 1 taken 29556 times.
✓ Branch 2 taken 1900845 times.
✓ Branch 3 taken 3361770 times.
5292171 else if(dmisc9==e9tNORMAL && wpn==0)
13388 {
13389
2/2
✓ Branch 0 taken 485805 times.
✓ Branch 1 taken 2875965 times.
3361770 if(dmisc2==e2tSPLITHIT) // Zol
13390 {
13391 485805 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
13392 485805 }
13393
4/4
✓ Branch 0 taken 965978 times.
✓ Branch 1 taken 1909987 times.
✓ Branch 2 taken 900443 times.
✓ Branch 3 taken 65535 times.
2875965 else if(frate<=8 && starting_hp==1) // Gel
13394 {
13395 65535 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
13396 65535 }
13397 else // Other
13398 {
13399 2810430 halting_walk(rate,homing,0,hrate, 48);
13400 }
13401 3361770 }
13402 else // Other
13403 {
13404 1930401 halting_walk(rate,homing,0,hrate, 48);
13405 }
13406 }
13407
13408 //if not in midair, and Hero's swinging sword is nearby, jump.
13409 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
13410 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
13411 {
13412 facehero(false);
13413 sclk=16+((dir^1)<<8);
13414 fall=-FEATHERJUMP;
13415 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
13416 }*/
13417 5528559 break;
13418
13419 // Following cases are for just after creation-by-splitting.
13420 case 1:
13421
2/2
✓ Branch 0 taken 1539 times.
✓ Branch 1 taken 508 times.
2047 if(misc==1)
13422 {
13423 508 dir=up;
13424 508 step=8;
13425 508 }
13426
13427
2/2
✓ Branch 0 taken 491 times.
✓ Branch 1 taken 1556 times.
2047 if(misc<=2)
13428 {
13429 1556 move(step);
13430
13431
2/2
✓ Branch 0 taken 1269 times.
✓ Branch 1 taken 287 times.
1556 if(!canmove(dir,(zfix)0,0,false))
13432 287 dir=down;
13433 1556 }
13434
13435
2/2
✓ Branch 0 taken 1556 times.
✓ Branch 1 taken 491 times.
2047 if(misc==3)
13436 {
13437
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 312 times.
491 if(canmove(right,(zfix)16,0,false))
13438 312 x+=16;
13439 491 }
13440
13441 2047 ++misc;
13442 2047 break;
13443
13444 case 2:
13445 if(misc==1)
13446 {
13447 dir=down;
13448 step=8;
13449 }
13450
13451 if(misc<=2)
13452 {
13453 move(step);
13454 /*
13455 if(!canmove(dir,(zfix)0,0,false))
13456 dir=up;
13457 */
13458 }
13459
13460 if(misc==3)
13461 {
13462 if(canmove(left,(zfix)16,0,false))
13463 x-=16;
13464 }
13465
13466 ++misc;
13467 break;
13468
13469 default:
13470 if(misc==1)
13471 {
13472 dir=(zc_oldrand()%4);
13473 step=8;
13474 }
13475
13476 if(misc<=2)
13477 {
13478 move(step);
13479
13480 if(!canmove(dir,(zfix)0,0,false))
13481 dir=dir^1;
13482 }
13483
13484 if(misc==3)
13485 {
13486 if(dir >= left && canmove(dir,(zfix)16,0,false))
13487 x+=(dir==left ? -16 : 16);
13488 }
13489
13490 ++misc;
13491 break;
13492 6341290 }
13493
13494
4/4
✓ Branch 0 taken 14221 times.
✓ Branch 1 taken 6658343 times.
✓ Branch 2 taken 13730 times.
✓ Branch 3 taken 491 times.
6672564 if(id>>12 && misc>=4) //recently spawned by a split enemy
13495 {
13496 491 id&=0xFFF;
13497 491 step = zslongToFix(dstep*100);
13498
13499
1/2
✓ Branch 0 taken 491 times.
✗ Branch 1 not taken.
491 if(x<32) x=32;
13500
13501
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 8 times.
491 if(x>208) x=208;
13502
13503
2/2
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 13 times.
491 if(y<32) y=32;
13504
13505
2/2
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 5 times.
491 if(y>128) y=128;
13506
13507 491 misc=3;
13508 491 }
13509 6672564 }
13510 else
13511 {
13512 //sfx(wpnsfx(wpn),pan(int32_t(x)));
13513
1/2
✓ Branch 0 taken 187167 times.
✗ Branch 1 not taken.
187167 if(clk2>2) clk2--;
13514 }
13515
13516 // Fire Zol
13517
7/8
✓ Branch 0 taken 2581202 times.
✓ Branch 1 taken 4280750 times.
✓ Branch 2 taken 6634 times.
✓ Branch 3 taken 2574568 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 6587 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 47 times.
6861952 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
13518 {
13519 47 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
13520 47 sfx(wpnsfx(wpn),pan(int32_t(x)));
13521
13522 47 int32_t i=Ewpns.Count()-1;
13523 47 weapon *ew = (weapon*)(Ewpns.spr(i));
13524
13525
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
13526 {
13527 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
13528 if ( ew->do_animation ) ew->tile+=ew->aframe;
13529 }
13530 47 }
13531 // Goriya
13532
14/16
✓ Branch 0 taken 438916 times.
✓ Branch 1 taken 6422989 times.
✓ Branch 2 taken 205580 times.
✓ Branch 3 taken 233336 times.
✓ Branch 4 taken 199606 times.
✓ Branch 5 taken 5974 times.
✓ Branch 6 taken 182448 times.
✓ Branch 7 taken 17158 times.
✓ Branch 8 taken 182448 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 180226 times.
✓ Branch 11 taken 2222 times.
✓ Branch 12 taken 180226 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 177570 times.
✓ Branch 15 taken 2656 times.
6861905 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
13533 {
13534 2656 misc=index+100;
13535
7/14
✓ Branch 0 taken 2656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2656 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2656 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2656 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2656 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2656 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2656 times.
✗ Branch 13 not taken.
2656 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
13536 2656 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
13537
13538
2/2
✓ Branch 0 taken 2501 times.
✓ Branch 1 taken 155 times.
2656 if(dmisc1==2)
13539 {
13540 155 int32_t ndir=dir;
13541
13542
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 151 times.
155 if(Hero.x-x==0)
13543 {
13544 4 ndir=(Hero.y+8<y)?up:down;
13545 4 }
13546 else //turn to face Hero
13547 {
13548 double _MSVC2022_tmp1, _MSVC2022_tmp2;
13549 151 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
13550
13551
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 9 times.
151 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
13552 {
13553 9 ndir=down;
13554 9 }
13555
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 41 times.
142 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
13556 {
13557 41 ndir=right;
13558 41 }
13559
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 33 times.
101 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
13560 {
13561 33 ndir=up;
13562 33 }
13563 else
13564 {
13565 68 ndir=left;
13566 }
13567 }
13568
13569 155 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
13570
13571
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 153 times.
155 if(canmove(ndir,false))
13572 {
13573 153 dir=ndir;
13574 153 }
13575 155 }
13576 2656 }
13577
15/16
✓ Branch 0 taken 6831913 times.
✓ Branch 1 taken 27336 times.
✓ Branch 2 taken 102427 times.
✓ Branch 3 taken 6756822 times.
✓ Branch 4 taken 90516 times.
✓ Branch 5 taken 11911 times.
✓ Branch 6 taken 75809 times.
✓ Branch 7 taken 14707 times.
✓ Branch 8 taken 75210 times.
✓ Branch 9 taken 599 times.
✓ Branch 10 taken 70403 times.
✓ Branch 11 taken 4807 times.
✓ Branch 12 taken 70403 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 69459 times.
6859249 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
13578
3/3
✓ Branch 0 taken 10948 times.
✓ Branch 1 taken 57610 times.
✓ Branch 2 taken 901 times.
69459 switch(dmisc1)
13579 {
13580 case e1tCONSTANT: //Deathnut
13581 {
13582 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
13583
2/2
✓ Branch 0 taken 56404 times.
✓ Branch 1 taken 1206 times.
57610 if(clk5>64)
13584 {
13585 1206 clk5=0;
13586 1206 fired=false;
13587 1206 }
13588
13589 57610 clk5+=(zc_oldrand()&3);
13590
13591
4/4
✓ Branch 0 taken 35436 times.
✓ Branch 1 taken 22174 times.
✓ Branch 2 taken 12000 times.
✓ Branch 3 taken 23436 times.
57610 if((clk5>24)&&(clk5<52))
13592 {
13593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23436 times.
23436 if ( do_animation )tile+=20; //firing
13594
13595
4/4
✓ Branch 0 taken 12824 times.
✓ Branch 1 taken 10612 times.
✓ Branch 2 taken 11525 times.
✓ Branch 3 taken 1299 times.
23436 if(!fired&&(clk5>=38))
13596 {
13597
5/10
✓ Branch 0 taken 1299 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1299 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1299 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1299 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1299 times.
✗ Branch 9 not taken.
1299 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
13598 1299 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
13599 1299 sfx(wpnsfx(wpn),pan(int32_t(x)));
13600 1299 fired=true;
13601 1299 }
13602 23436 }
13603
13604 57610 break;
13605 }
13606
13607 case e1tFIREOCTO: //Fire Octo
13608 901 timer=zc_oldrand()%50+50;
13609 901 break;
13610
13611 default:
13612 10948 FireWeapon();
13613 10948 break;
13614 69459 }
13615
13616 /* Fire again if:
13617 * - clk2 about to run out
13618 * - not already double-firing (dmisc1 is 1)
13619 * - not carrying Hero
13620 * - one in 0xF chance
13621 */
13622
8/10
✓ Branch 0 taken 231061 times.
✓ Branch 1 taken 6630891 times.
✓ Branch 2 taken 2272 times.
✓ Branch 3 taken 228789 times.
✓ Branch 4 taken 2272 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2272 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 2119 times.
6861952 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
13623 {
13624 #if 1
13625 153 newdir(rate, homing, grumble);
13626 #else
13627 dir^=2;
13628 #endif
13629 153 clk2=28;
13630 153 ++multishot;
13631 153 }
13632
13633
2/2
✓ Branch 0 taken 1684557 times.
✓ Branch 1 taken 5177395 times.
6861952 if(clk2==0)
13634 {
13635 5177395 multishot = 0;
13636 5177395 }
13637
13638
2/2
✓ Branch 0 taken 6797835 times.
✓ Branch 1 taken 64117 times.
6861952 if(timer) //Fire Octo
13639 {
13640 64117 clk2=15; //this keeps the octo in place until he's done firing
13641
13642
2/2
✓ Branch 0 taken 48413 times.
✓ Branch 1 taken 15704 times.
64117 if(!(timer%4))
13643 {
13644 15704 FireBreath(false);
13645 15704 }
13646
13647 64117 --timer;
13648 64117 }
13649
13650
2/2
✓ Branch 0 taken 6696965 times.
✓ Branch 1 taken 164987 times.
6861952 if(dmisc2==e2tTRIBBLE)
13651 164987 ++clk4;
13652
13653
7/10
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 6859712 times.
✓ Branch 2 taken 588 times.
✓ Branch 3 taken 6861364 times.
✓ Branch 4 taken 588 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 588 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 588 times.
6861952 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
13654 {
13655 588 int32_t kids = guys.Count();
13656 588 int32_t id2=dmisc3;
13657
13658
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 588 times.
1176 for(int32_t i=0; i<dmisc4; i++)
13659 {
13660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
588 if(addenemy(x,y,id2,-24))
13661 {
13662
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 if(itemguy) // Hand down the carried item
13663 {
13664 guycarryingitem = guys.Count()-1;
13665 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13666 itemguy = false;
13667 }
13668
13669 588 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13670 588 }
13671 588 }
13672
13673
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 if(hashero)
13674 {
13675 Hero.setEaten(0);
13676 hashero=false;
13677 }
13678
13679 588 stop_bgsfx(index);
13680 588 return true;
13681 }
13682
13683 6861364 return enemy::animate(index);
13684 7027045 }
13685
13686 7332153 void eStalfos::draw(BITMAP *dest)
13687 {
13688 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
13689 {
13690 clk4--; //Kludge
13691 return;
13692 }*/
13693
13694 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
13695 {
13696 cs = dcset;
13697 }*/
13698 7332153 update_enemy_frame();
13699
13700
7/8
✓ Branch 0 taken 7332011 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 7332011 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35975 times.
✓ Branch 5 taken 7296036 times.
✓ Branch 6 taken 33085 times.
✓ Branch 7 taken 2890 times.
7332153 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
13701 {
13702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if ( do_animation )tile+=20;
13703 2890 }
13704
13705 7332153 enemy::draw(dest);
13706 7332153 }
13707
13708 1816775 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
13709 {
13710 1816775 int32_t tempy=yofs;
13711
13712 /*
13713 if (clk6 && dir>=left && !get_bit(quest_rules,qr_ENEMIESZAXIS)) {
13714 flip = 0;
13715 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13716 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
13717 shadowtile = wpnsbuf[spr_shadow].tile+f2;
13718 yofs+=(((int32_t)y+17)&0xF0)-y;
13719 yofs+=8;
13720 }
13721 */
13722
3/4
✓ Branch 0 taken 1736002 times.
✓ Branch 1 taken 80773 times.
✓ Branch 2 taken 1816775 times.
✗ Branch 3 not taken.
1816775 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_bit(quest_rules,qr_ENEMIESZAXIS))
13723 {
13724 flip = 0;
13725 int32_t fdiv = frate/4;
13726 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13727
13728 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13729 efrate:((clk>=(frate>>1))?1:0);
13730 shadowtile = wpnsbuf[spr_shadow].tile;
13731
13732 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13733 {
13734 shadowtile+=f2;
13735 }
13736 else
13737 {
13738 shadowtile+=f2?1:0;
13739 }
13740
13741 yofs+=shadowdistance;
13742 yofs+=8;
13743 }
13744
3/4
✓ Branch 0 taken 1736002 times.
✓ Branch 1 taken 80773 times.
✓ Branch 2 taken 1816775 times.
✗ Branch 3 not taken.
1816775 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_bit(quest_rules,qr_POLVIRE_NO_SHADOW))
13745 {
13746 flip = 0;
13747 int32_t fdiv = frate/4;
13748 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13749
13750 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13751 efrate:((clk>=(frate>>1))?1:0);
13752 shadowtile = wpnsbuf[spr_shadow].tile;
13753
13754 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13755 {
13756 shadowtile+=f2;
13757 }
13758 else
13759 {
13760 shadowtile+=f2?1:0;
13761 }
13762 }
13763
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 1816633 times.
1816775 if(!shadow_overpit(this))
13764 1816633 enemy::drawshadow(dest, translucent);
13765 1816775 yofs=tempy;
13766 1816775 }
13767
13768 78749 int32_t eStalfos::takehit(weapon *w)
13769 {
13770 78749 int32_t wpnId = w->id;
13771 78749 int32_t wpnDir = w->dir;
13772
13773
4/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 78642 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 72 times.
78749 if(wpnId==wHammer && shield && (flags & guy_bkshield)
13774
5/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
35 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
13775
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
13776 {
13777 23 shield = false;
13778 23 flags &= ~(inv_left|inv_right|inv_back|inv_front);
13779
13780
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 22 times.
23 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
13781 1 o_tile=s_tile;
13782 23 }
13783
13784 78749 int32_t ret = enemy::takehit(w);
13785
13786
4/4
✓ Branch 0 taken 9022 times.
✓ Branch 1 taken 69727 times.
✓ Branch 2 taken 7954 times.
✓ Branch 3 taken 1068 times.
78749 if(sclk && dmisc2==e2tSPLITHIT)
13787 1068 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
13788
13789 78749 return ret;
13790 }
13791
13792 454101 void eStalfos::charge_attack()
13793 {
13794
2/2
✓ Branch 0 taken 4498 times.
✓ Branch 1 taken 449603 times.
454101 if(slide())
13795 4498 return;
13796
13797
9/12
✓ Branch 0 taken 449603 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 449603 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 436092 times.
✓ Branch 5 taken 13511 times.
✓ Branch 6 taken 420323 times.
✓ Branch 7 taken 15769 times.
✓ Branch 8 taken 416157 times.
✓ Branch 9 taken 4166 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 416157 times.
449603 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
13798 33446 return;
13799
13800
2/2
✓ Branch 0 taken 16836 times.
✓ Branch 1 taken 399321 times.
416157 if(clk3<=0)
13801 {
13802 16836 fix_coords(true);
13803
13804
2/2
✓ Branch 0 taken 4921 times.
✓ Branch 1 taken 11915 times.
16836 if(!dashing)
13805 {
13806 11915 int32_t ldir = lined_up(7,false);
13807
13808
4/4
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 10727 times.
✓ Branch 2 taken 1016 times.
✓ Branch 3 taken 172 times.
11915 if(ldir!=-1 && canmove(ldir,false))
13809 {
13810 1016 dir=ldir;
13811 1016 dashing=true;
13812 1016 step=zslongToFix(dstep*100)+1;
13813 1016 }
13814 10899 else newdir(4,0,0);
13815 11915 }
13816
13817
2/2
✓ Branch 0 taken 16211 times.
✓ Branch 1 taken 625 times.
16836 if(!canmove(dir,false))
13818 {
13819 625 step=zslongToFix(dstep*100);
13820 625 newdir();
13821 625 dashing=false;
13822 625 }
13823
13824 16836 zfix div = step;
13825
13826
1/2
✓ Branch 0 taken 16836 times.
✗ Branch 1 not taken.
16836 if(div == 0)
13827 div = 1;
13828
13829 16836 clk3=(int32_t)(16.0/div);
13830 16836 return;
13831 }
13832
13833 399321 move(step);
13834 399321 --clk3;
13835 454101 }
13836
13837 356583 void eStalfos::vire_hop()
13838 {
13839 //if ( sclk > 0 ) return; //Don't hop during knockback.
13840
13841 // if(dmisc9!=e9tPOLSVOICE)
13842 // {
13843 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
13844 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
13845 // return; //the enemy should split if it is sliding!
13846 // //else sclk=0; //might need this here, too. -Z
13847 // }
13848
2/2
✓ Branch 0 taken 140019 times.
✓ Branch 1 taken 216564 times.
356583 if(dmisc9!=e9tPOLSVOICE)
13849 {
13850
2/2
✓ Branch 0 taken 135236 times.
✓ Branch 1 taken 4783 times.
140019 if(sclk!=0)
13851 {
13852
2/2
✓ Branch 0 taken 940 times.
✓ Branch 1 taken 3843 times.
4783 if (dmisc2==e2tSPLITHIT) return;
13853 //return;
13854 3843 }
13855 139079 }
13856 216564 else sclk=0;
13857
13858
8/12
✓ Branch 0 taken 355643 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355643 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 348831 times.
✓ Branch 5 taken 6812 times.
✓ Branch 6 taken 339655 times.
✓ Branch 7 taken 9176 times.
✓ Branch 8 taken 339655 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 339655 times.
355643 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
13859 15988 return;
13860
13861 339655 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
13862 339655 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
13863
13864 339655 y=floor_y;
13865
13866
2/2
✓ Branch 0 taken 328455 times.
✓ Branch 1 taken 11200 times.
339655 if(clk3<=0)
13867 {
13868 11200 fix_coords();
13869
13870 //z=0;
13871 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
13872 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
13873
9/10
✓ Branch 0 taken 2307 times.
✓ Branch 1 taken 8893 times.
✓ Branch 2 taken 2051 times.
✓ Branch 3 taken 256 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 1957 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
11200 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV)))) //Vires in old quests
13874 9243 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
13875
13876
2/2
✓ Branch 0 taken 2307 times.
✓ Branch 1 taken 8893 times.
11200 if(clk2<=0)
13877 {
13878 //z=0;
13879
6/6
✓ Branch 0 taken 8131 times.
✓ Branch 1 taken 762 times.
✓ Branch 2 taken 7922 times.
✓ Branch 3 taken 209 times.
✓ Branch 4 taken 5674 times.
✓ Branch 5 taken 2248 times.
8893 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
13880 {
13881
13882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6645 times.
6645 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
13883 /*if (dmisc9==e9tPOLSVOICE )
13884 {
13885 zprint2("polsvoice jump_width is: %d\n", jump_width);
13886 zprint2("polsvoice raw step is: %d\n", step);
13887 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
13888 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
13889 }
13890 else
13891 {
13892 zprint2("vire jump_width is: %d\n", jump_width);
13893 zprint2("vire raw step is: %d\n", step);
13894 zprint2("vire step.getInt() is: %d\n", step.getInt());
13895 zprint2("setting clk2 on vire to: %d\n", clk2);
13896 }
13897 */
13898 6645 }
13899 8893 }
13900
13901
4/4
✓ Branch 0 taken 4376 times.
✓ Branch 1 taken 6824 times.
✓ Branch 2 taken 2003 times.
✓ Branch 3 taken 2373 times.
11200 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
13902 {
13903 2373 clk2=int32_t((16.0*jump_width)/step.getFloat());
13904 2373 }
13905
13906 11200 clk3=int32_t(16.0/step.getFloat());
13907 11200 }
13908
13909 339655 --clk3;
13910
13911
3/4
✓ Branch 0 taken 131106 times.
✓ Branch 1 taken 208549 times.
✓ Branch 2 taken 131106 times.
✗ Branch 3 not taken.
339655 if(dmisc9==e9tPOLSVOICE || clk2>0)
13912 339655 move(step);
13913
13914 339655 floor_y=y;
13915 339655 clk2--;
13916
13917 //if we're in the middle of a jump
13918
6/6
✓ Branch 0 taken 262151 times.
✓ Branch 1 taken 77504 times.
✓ Branch 2 taken 111548 times.
✓ Branch 3 taken 150603 times.
✓ Branch 4 taken 53385 times.
✓ Branch 5 taken 58163 times.
339655 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
13919 {
13920 203988 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
13921
13922
4/4
✓ Branch 0 taken 97084 times.
✓ Branch 1 taken 106904 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 90933 times.
203988 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
13923 {
13924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90933 times.
90933 if (moveflags & FLAG_USE_FAKE_Z) fakez=h;
13925 90933 else z=h;
13926 90933 }
13927 else
13928 {
13929 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
13930 //y-=h;
13931 113055 y=floor_y-h;
13932 113055 shadowdistance=h;
13933 }
13934 203988 }
13935 else
13936 135667 shadowdistance = 0;
13937 356583 }
13938
13939 47 void eStalfos::eathero()
13940 {
13941
5/8
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 28 times.
47 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
13942 {
13943 28 hashero=true;
13944 28 y=floor_y;
13945 28 z=0;
13946
13947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(Hero.isSwimming())
13948 {
13949 Hero.setX(x);
13950 Hero.setY(y);
13951 }
13952 else
13953 {
13954 28 x=Hero.getX();
13955 28 y=Hero.getY();
13956 }
13957
13958 28 clk2=0;
13959 28 }
13960 47 }
13961
13962 619142 bool eStalfos::WeaponOut()
13963 {
13964
2/2
✓ Branch 0 taken 1266387 times.
✓ Branch 1 taken 254405 times.
1520792 for(int32_t i=0; i<Ewpns.Count(); i++)
13965 {
13966
3/4
✓ Branch 0 taken 364737 times.
✓ Branch 1 taken 901650 times.
✓ Branch 2 taken 364737 times.
✗ Branch 3 not taken.
1266387 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
13967 {
13968 364737 return true;
13969 }
13970
13971 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
13972 stop_sfx(bgsfx);
13973 */
13974 901650 }
13975
13976 254405 return false;
13977 619142 }
13978
13979 156550 void eStalfos::KillWeapon()
13980 {
13981
2/2
✓ Branch 0 taken 156550 times.
✓ Branch 1 taken 169200 times.
325750 for(int32_t i=0; i<Ewpns.Count(); i++)
13982 {
13983
4/4
✓ Branch 0 taken 144447 times.
✓ Branch 1 taken 24753 times.
✓ Branch 2 taken 144005 times.
✓ Branch 3 taken 442 times.
169200 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
13984 {
13985 //only kill this Goriya's boomerang -DD
13986
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 182 times.
442 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
13987 {
13988 182 Ewpns.del(i);
13989 182 }
13990 442 }
13991 169200 }
13992
13993
4/4
✓ Branch 0 taken 13138 times.
✓ Branch 1 taken 143412 times.
✓ Branch 2 taken 6365 times.
✓ Branch 3 taken 6773 times.
156550 if(wpn==ewBrang && !Ewpns.idCount(ewBrang))
13994 {
13995 6365 stop_sfx(WAV_BRANG);
13996 6365 }
13997 156550 }
13998
13999 void eStalfos::break_shield()
14000 {
14001 if(!shield)
14002 return;
14003
14004 flags&=~(inv_front | inv_back | inv_left | inv_right);
14005 shield=false;
14006
14007 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
14008 o_tile=s_tile;
14009 }
14010
14011 8964 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14012 8964 {
14013
1/2
✓ Branch 0 taken 4482 times.
✗ Branch 1 not taken.
4482 dir=(zc_oldrand()&7)+8;
14014
1/2
✓ Branch 0 taken 4482 times.
✗ Branch 1 not taken.
4482 step=0;
14015 4482 movestatus=1;
14016
3/4
✓ Branch 0 taken 3526 times.
✓ Branch 1 taken 956 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3526 times.
4482 if (dmisc1 != 1 && dmisc19 > 0)
14017 {
14018 step = dmisc19/100.0;
14019 movestatus = 1;
14020 }
14021
1/2
✓ Branch 0 taken 4482 times.
✗ Branch 1 not taken.
4482 if (dmisc1 == 2) movestatus=2;
14022 4482 c=0;
14023 4482 SIZEflags = d->SIZEflags;
14024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
4482 if ( !(SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ) hxofs=2;
14025
1/2
✓ Branch 0 taken 4482 times.
✗ Branch 1 not taken.
4482 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
14026
14027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
4482 if ( !(SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ) hxsz=12;
14028
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4482 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
14029
14030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
4482 if ( !(SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ) hyofs=4;
14031
1/2
✓ Branch 0 taken 4482 times.
✗ Branch 1 not taken.
4482 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14032
14033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
4482 if ( !(SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ) hysz=8;
14034
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4482 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
14035
14036
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4482 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14037 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
14038 // al_trace("Enemy txsz:%i\n", txsz);
14039
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4482 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14040
14041
14042
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4482 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
14043
14044
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4482 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
14045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
4482 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14046 {
14047 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14048 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14049 }
14050
14051
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4482 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
14052 4482 clk4=0;
14053 //nets;
14054 4482 dummy_int[1]=0;
14055 4482 }
14056
14057 1377114 bool eKeese::animate(int32_t index)
14058 {
14059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1377114 times.
1377114 if(switch_hooked) return enemy::animate(index);
14060
2/4
✓ Branch 0 taken 1377114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1377114 times.
1377114 if(fallclk||drownclk) return enemy::animate(index);
14061
2/2
✓ Branch 0 taken 52218 times.
✓ Branch 1 taken 1324896 times.
1377114 if(dying)
14062 52218 return Dead(index);
14063
14064
2/2
✓ Branch 0 taken 1317481 times.
✓ Branch 1 taken 7415 times.
1324896 if(clk==0)
14065 {
14066 7415 removearmos(x,y,ffcactivated);
14067 7415 }
14068
14069
2/2
✓ Branch 0 taken 368335 times.
✓ Branch 1 taken 956561 times.
1324896 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
14070 {
14071 368335 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
14072 368335 }
14073 else
14074 {
14075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 956561 times.
956561 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
14076 956561 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
14077 }
14078
14079
2/2
✓ Branch 0 taken 14165 times.
✓ Branch 1 taken 1310731 times.
1324896 if(dmisc2 == e2tKEESETRIB)
14080 {
14081
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14165 times.
✓ Branch 2 taken 14135 times.
✓ Branch 3 taken 30 times.
14165 if(++clk4==(dmisc20>0?dmisc20:256))
14082 {
14083
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 19 times.
30 if(!m_walkflag(x,y,0, dir))
14084 {
14085 19 int32_t kids = guys.Count();
14086 19 bool success = false;
14087 19 int32_t id2=dmisc3;
14088 19 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
14089
14090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if(success)
14091 {
14092
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemguy) // Hand down the carried item
14093 {
14094 guycarryingitem = guys.Count()-1;
14095 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
14096 itemguy = false;
14097 }
14098
14099 19 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
14100 19 }
14101
14102 19 stop_bgsfx(index);
14103 19 return true;
14104 }
14105 else
14106 {
14107 11 clk4=0;
14108 }
14109 11 }
14110 14146 }
14111 // Keese Tribbles stay on the ground, so there's no problem when they transform.
14112
3/4
✓ Branch 0 taken 483168 times.
✓ Branch 1 taken 827563 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 483168 times.
1310731 else if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
14113 {
14114
1/2
✓ Branch 0 taken 483168 times.
✗ Branch 1 not taken.
483168 if (get_bit(quest_rules,qr_OLD_KEESE_Z_AXIS))
14115 {
14116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 483168 times.
483168 if (moveflags & FLAG_USE_FAKE_Z)
14117 {
14118 fakez=int32_t(step/zslongToFix(dstep*100));
14119 // Some variance in keese flight heights when away from Hero
14120 fakez+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-128)/10));
14121
14122 }
14123 else
14124 {
14125 483168 z=int32_t(step/zslongToFix(dstep*100));
14126 // Some variance in keese flight heights when away from Hero
14127
2/2
✓ Branch 0 taken 392397 times.
✓ Branch 1 taken 90771 times.
483168 z+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-128)/10));
14128 }
14129 483168 }
14130 else
14131 {
14132 if (moveflags & FLAG_USE_FAKE_Z)
14133 {
14134 fakez=int32_t(step/zslongToFix(dstep*100));
14135 // Some variance in keese flight heights when away from Hero
14136 fakez+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-40)/4));
14137
14138 }
14139 else
14140 {
14141 z=int32_t(step/zslongToFix(dstep*100));
14142 // Some variance in keese flight heights when away from Hero
14143 z+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-40)/4));
14144 }
14145 }
14146 483168 }
14147
14148 1324877 return enemy::animate(index);
14149 1377114 }
14150
14151 376313 void eKeese::drawshadow(BITMAP *dest, bool translucent)
14152 {
14153 376313 int32_t tempy=yofs;
14154 376313 flip = 0;
14155 376313 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
14156
14157
2/2
✓ Branch 0 taken 129846 times.
✓ Branch 1 taken 246467 times.
376313 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
14158
2/2
✓ Branch 0 taken 302522 times.
✓ Branch 1 taken 73791 times.
376313 if(!get_bit(quest_rules,qr_ENEMIESZAXIS))
14159 {
14160 73791 yofs+=int32_t(step/zslongToFix(dstep*10));
14161 73791 }
14162
14163
6/6
✓ Branch 0 taken 372719 times.
✓ Branch 1 taken 3594 times.
✓ Branch 2 taken 302522 times.
✓ Branch 3 taken 70197 times.
✓ Branch 4 taken 294452 times.
✓ Branch 5 taken 8070 times.
376313 if(!shadow_overpit(this) && (!get_bit(quest_rules,qr_ENEMIESZAXIS) || step > 0))
14164 364649 enemy::drawshadow(dest, translucent);
14165 376313 yofs=tempy;
14166 376313 }
14167
14168 3222716 void eKeese::draw(BITMAP *dest)
14169 {
14170 3222716 update_enemy_frame();
14171 3222716 enemy::draw(dest);
14172 3222716 }
14173
14174 10306 void eWizzrobe::submerge(bool set)
14175 {
14176
2/2
✓ Branch 0 taken 10278 times.
✓ Branch 1 taken 28 times.
10306 if(get_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING))
14177 {
14178 10278 hxofs = set?1000:0;
14179 10278 return;
14180 }
14181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(submerged == set) return;
14182 28 submerged = set;
14183
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(set)
14184 14 hxofs+=1000;
14185 14 else hxofs -= 1000;
14186 10306 }
14187 3324 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14188 3324 {
14189 1662 hxofs = 0;
14190 1662 submerged = false;
14191
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 1002 times.
1662 switch(dmisc1)
14192 {
14193 case 0:
14194
1/2
✓ Branch 0 taken 1002 times.
✗ Branch 1 not taken.
1002 submerge(true);
14195 1002 fading=fade_invisible;
14196 // Set clk to just before the 'reappear' threshold
14197
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1002 times.
✓ Branch 4 taken 801 times.
✓ Branch 5 taken 201 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 801 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 201 times.
1002 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
14198 1002 break;
14199
14200 default:
14201 660 dir=(loadside==right)?right:left;
14202 660 misc=-3;
14203 660 break;
14204 }
14205
14206 //netst+2880;
14207 1662 charging=false;
14208 1662 firing=false;
14209 1662 fclk=0;
14210
2/2
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 660 times.
1662 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
14211 1662 SIZEflags = d->SIZEflags;
14212
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1662 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14213 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14214 // al_trace("Enemy txsz:%i\n", txsz);
14215
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1662 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14216
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1662 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
14217
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1662 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
14218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1662 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
14219
1/2
✓ Branch 0 taken 1662 times.
✗ Branch 1 not taken.
1662 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 )
14220 {
14221 hxofs = (submerged?hxofs:0)+d->hxofs;
14222 }
14223
1/2
✓ Branch 0 taken 1662 times.
✗ Branch 1 not taken.
1662 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14224 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14225
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1662 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
1662 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14227 {
14228 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14229 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14230 }
14231
14232
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1662 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
14233 1662 }
14234
14235 830438 bool eWizzrobe::animate(int32_t index)
14236 {
14237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 830438 times.
830438 if(switch_hooked) return enemy::animate(index);
14238
2/4
✓ Branch 0 taken 830438 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 830438 times.
830438 if(fallclk||drownclk) return enemy::animate(index);
14239
2/2
✓ Branch 0 taken 18856 times.
✓ Branch 1 taken 811582 times.
830438 if(dying)
14240 {
14241 18856 return Dead(index);
14242 }
14243
14244
2/2
✓ Branch 0 taken 786501 times.
✓ Branch 1 taken 25081 times.
811582 if(clk==0)
14245 {
14246 25081 removearmos(x,y,ffcactivated);
14247 25081 }
14248
14249
2/2
✓ Branch 0 taken 401978 times.
✓ Branch 1 taken 409604 times.
811582 if(dmisc1) // Floating
14250 {
14251 401978 wizzrobe_attack();
14252 401978 }
14253 else // Teleporting
14254 {
14255
5/6
✓ Branch 0 taken 404251 times.
✓ Branch 1 taken 5353 times.
✓ Branch 2 taken 2710 times.
✓ Branch 3 taken 401541 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2710 times.
409604 if(watch || (!get_bit(quest_rules, qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
14256 {
14257 5353 fading=0;
14258 5353 submerge(false);
14259 5353 solid_update(false);
14260 5353 }
14261
8/8
✓ Branch 0 taken 390812 times.
✓ Branch 1 taken 2397 times.
✓ Branch 2 taken 2096 times.
✓ Branch 3 taken 2026 times.
✓ Branch 4 taken 1991 times.
✓ Branch 5 taken 1717 times.
✓ Branch 6 taken 1658 times.
✓ Branch 7 taken 1554 times.
404251 else switch(clk)
14262 {
14263 case 0:
14264
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 1916 times.
2397 if(!dmisc2)
14265 {
14266 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
14267 // but should not appear on dungeon walls.
14268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1916 times.
1916 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
14269
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 1871 times.
1916 else if (editorflags&ENEMY_FLAG5)
14270 {
14271 //2.10 Windrobe
14272 //randomise location and face Hero
14273 45 int32_t t=0;
14274 45 bool placed=false;
14275
14276
4/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 45 times.
96 while(!placed && t<160)
14277 {
14278
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(isdungeon())
14279 {
14280 51 x=((zc_oldrand()%12)+2)*16;
14281 51 y=((zc_oldrand()%7)+2)*16;
14282 51 }
14283 else
14284 {
14285 x=((zc_oldrand()%14)+1)*16;
14286 y=((zc_oldrand()%9)+1)*16;
14287 }
14288
14289
6/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 45 times.
101 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
14290 {
14291 45 placed=true;
14292 45 }
14293
14294 51 ++t;
14295 }
14296
14297
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 31 times.
45 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
14298 {
14299
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5 times.
14 if(y<Hero.getY())
14300 {
14301 9 dir=down;
14302 9 }
14303 else
14304 {
14305 5 dir=up;
14306 }
14307 14 }
14308 else
14309 {
14310
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 15 times.
31 if(x<Hero.getX())
14311 {
14312 15 dir=right;
14313 15 }
14314 else
14315 {
14316 16 dir=left;
14317 }
14318 }
14319
14320
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!placed) // can't place him, he's gone
14321 return true;
14322
14323
14324 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
14325 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
14326 45 }
14327 1871 else place_on_axis(true, dmisc4!=0);
14328 1916 }
14329 else
14330 {
14331 481 int32_t t=0;
14332 481 bool placed=false;
14333
14334
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 641 times.
✓ Branch 3 taken 481 times.
1122 while(!placed && t<160)
14335 {
14336
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 17 times.
641 if(isdungeon())
14337 {
14338 624 x=((zc_oldrand()%12)+2)*16;
14339 624 y=((zc_oldrand()%7)+2)*16;
14340 624 }
14341 else
14342 {
14343 17 x=((zc_oldrand()%14)+1)*16;
14344 17 y=((zc_oldrand()%9)+1)*16;
14345 }
14346
14347
6/6
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 554 times.
✓ Branch 2 taken 389 times.
✓ Branch 3 taken 165 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 481 times.
1195 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
14348 {
14349 481 placed=true;
14350 481 }
14351
14352 641 ++t;
14353 }
14354
14355
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 322 times.
481 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
14356 {
14357
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 62 times.
159 if(y<Hero.getY())
14358 {
14359 97 dir=down;
14360 97 }
14361 else
14362 {
14363 62 dir=up;
14364 }
14365 159 }
14366 else
14367 {
14368
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 156 times.
322 if(x<Hero.getX())
14369 {
14370 166 dir=right;
14371 166 }
14372 else
14373 {
14374 156 dir=left;
14375 }
14376 }
14377
14378
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 if(!placed) // can't place him, he's gone
14379 return true;
14380 }
14381
14382 2397 fading=fade_flicker;
14383 2397 submerge(false);
14384 2397 solid_update(false);
14385 2397 break;
14386
14387 case 64:
14388 2096 fading=0;
14389 2096 charging=true;
14390 2096 break;
14391
14392 case 73:
14393 2026 charging=false;
14394 2026 firing=40;
14395 2026 break;
14396
14397 case 83:
14398 1991 wizzrobe_attack_for_real();
14399 1991 break;
14400
14401 case 119:
14402 1717 firing=false;
14403 1717 charging=true;
14404 1717 break;
14405
14406 case 128:
14407 1658 fading=fade_flicker;
14408 1658 charging=false;
14409 1658 break;
14410
14411 case 146:
14412 1554 fading=fade_invisible;
14413 1554 submerge(true);
14414 1554 solid_update(false);
14415
14416 [[fallthrough]];
14417 default:
14418
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392366 times.
✓ Branch 2 taken 389965 times.
✓ Branch 3 taken 2401 times.
392366 if(clk>=(146+zc_max(0,dmisc5)))
14419 2401 clk=-1;
14420
14421 392366 break;
14422 }
14423 }
14424
14425 811582 return enemy::animate(index);
14426 830438 }
14427
14428 3249 void eWizzrobe::wizzrobe_attack_for_real()
14429 {
14430
1/2
✓ Branch 0 taken 3249 times.
✗ Branch 1 not taken.
3249 if(wpn==0) // Edited enemies
14431 return;
14432
14433
2/2
✓ Branch 0 taken 773 times.
✓ Branch 1 taken 2476 times.
3249 if(dmisc2 == 0) //normal weapon
14434 {
14435 2476 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
14436 2476 sfx(WAV_WAND,pan(int32_t(x)));
14437 2476 }
14438
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 450 times.
773 else if(dmisc2 == 1) // ring of fire
14439 {
14440 323 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
14441 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14442 323 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
14443 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14444 323 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
14445 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14446 323 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
14447 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14448 323 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
14449 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14450 323 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
14451 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14452 323 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
14453 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14454 323 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
14455 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14456 323 sfx(WAV_FIRE,pan(int32_t(x)));
14457
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 283 times.
323 if (get_bit(quest_rules, qr_8WAY_SHOT_SFX)) sfx(WAV_FIRE,pan(int32_t(x)));
14458 else
14459 {
14460
2/18
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 264 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
283 switch(wpn)
14461 {
14462 19 case ewFireball: sfx(40,pan(int32_t(x))); break;
14463
14464 case ewArrow: sfx(1,pan(int32_t(x))); break; //Ghost.zh has 0?
14465 case ewBrang: sfx(4,pan(int32_t(x))); break; //Ghost.zh has 0?
14466 case ewSword: sfx(20,pan(int32_t(x))); break; //Ghost.zh has 0?
14467 case ewRock: sfx(51,pan(int32_t(x))); break;
14468 case ewMagic: sfx(32,pan(int32_t(x))); break;
14469 case ewBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
14470 case ewSBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
14471 case ewLitBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
14472 case ewLitSBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
14473 case ewFireTrail: sfx(13,pan(int32_t(x))); break;
14474 264 case ewFlame: sfx(13,pan(int32_t(x))); break;
14475 case ewWind: sfx(32,pan(int32_t(x))); break;
14476 case ewFlame2: sfx(13,pan(int32_t(x))); break;
14477 case ewFlame2Trail: sfx(13,pan(int32_t(x))); break;
14478 case ewIce: sfx(44,pan(int32_t(x))); break;
14479 case ewFireball2: sfx(40,pan(int32_t(x))); break; //fireball (rising)
14480 default: sfx(WAV_FIRE,pan(int32_t(x))); break;
14481
14482 }
14483 }
14484 323 }
14485
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 14 times.
450 else if(dmisc2==2) // summons specific enemy
14486 {
14487 436 int32_t bc=0;
14488
14489
2/2
✓ Branch 0 taken 5394 times.
✓ Branch 1 taken 436 times.
5830 for(int32_t gc=0; gc<guys.Count(); gc++)
14490 {
14491
2/2
✓ Branch 0 taken 2590 times.
✓ Branch 1 taken 2804 times.
5394 if((((enemy*)guys.spr(gc))->id) == dmisc3)
14492 {
14493 2804 ++bc;
14494 2804 }
14495 5394 }
14496
14497
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 428 times.
436 if(bc<=40)
14498 {
14499 428 int32_t kids = guys.Count();
14500 428 int32_t bats=(zc_oldrand()%3)+1;
14501
14502
2/2
✓ Branch 0 taken 868 times.
✓ Branch 1 taken 428 times.
1296 for(int32_t i=0; i<bats; i++)
14503 {
14504 // Summon bats (or anything)
14505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 868 times.
868 if(addchild(x,y,dmisc3,-10, this->script_UID))
14506 868 ((enemy*)guys.spr(kids+i))->count_enemy = false;
14507 868 }
14508
14509 428 sfx(WAV_FIRE,pan(int32_t(x)));
14510 428 }
14511 436 }
14512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(dmisc2==3) //summon from layer
14513 {
14514
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count_layer_enemies()==0)
14515 {
14516 return;
14517 }
14518
14519 14 int32_t kids = guys.Count();
14520
14521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(kids<200)
14522 {
14523 14 int32_t newguys=(zc_oldrand()%3)+1;
14524 14 bool summoned=false;
14525
14526
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14 times.
39 for(int32_t i=0; i<newguys; i++)
14527 {
14528 25 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
14529 25 int32_t x2=0;
14530 25 int32_t y2=0;
14531
14532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t k=0; k<20; ++k)
14533 {
14534 27 x2=16*((zc_oldrand()%12)+2);
14535 27 y2=16*((zc_oldrand()%7)+2);
14536
14537
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 25 times.
54 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
14538 {
14539
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(addchild(x2,y2,get_bit(quest_rules,qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
14540 {
14541 25 ((enemy*)guys.spr(kids+i))->count_enemy = false;
14542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if (get_bit(quest_rules,qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
14543 {
14544 ((enemy*)guys.spr(kids+i))->fakez = 64;
14545 ((enemy*)guys.spr(kids+i))->z = 0;
14546 }
14547 25 }
14548
14549 25 summoned=true;
14550 25 break;
14551 }
14552 2 }
14553 25 }
14554
14555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(summoned)
14556 {
14557 14 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
14558 14 }
14559 14 }
14560 14 }
14561 3249 }
14562
14563
14564 401978 void eWizzrobe::wizzrobe_attack()
14565 {
14566
9/12
✓ Branch 0 taken 391428 times.
✓ Branch 1 taken 10550 times.
✓ Branch 2 taken 391428 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 382265 times.
✓ Branch 5 taken 9163 times.
✓ Branch 6 taken 380114 times.
✓ Branch 7 taken 2151 times.
✓ Branch 8 taken 380114 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 380114 times.
401978 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
14567 21864 return;
14568
14569
3/8
✓ Branch 0 taken 365267 times.
✓ Branch 1 taken 14847 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 365267 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
380114 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
14570 {
14571 14847 fix_coords();
14572
14573
5/5
✓ Branch 0 taken 1668 times.
✓ Branch 1 taken 497 times.
✓ Branch 2 taken 7340 times.
✓ Branch 3 taken 3520 times.
✓ Branch 4 taken 1822 times.
14847 switch(misc)
14574 {
14575 case 1: //walking
14576
2/2
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 875 times.
3520 if(!m_walkflag(x,y,spw_door, dir))
14577 875 misc=0;
14578 else
14579 {
14580 2645 clk3=16;
14581
14582
2/2
✓ Branch 0 taken 2332 times.
✓ Branch 1 taken 313 times.
2645 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
14583 {
14584 313 wizzrobe_newdir(0);
14585 313 }
14586 }
14587
14588 3520 break;
14589
14590 case 2: //phasing
14591 {
14592 1822 int32_t jx=x;
14593 1822 int32_t jy=y;
14594 1822 int32_t jdir=-1;
14595
14596
5/5
✓ Branch 0 taken 929 times.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 212 times.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 228 times.
1822 switch(zc_oldrand()&7)
14597 {
14598 case 0:
14599 231 jx-=32;
14600 231 jy-=32;
14601 231 jdir=15;
14602 231 break;
14603
14604 case 1:
14605 212 jx+=32;
14606 212 jy-=32;
14607 212 jdir=9;
14608 212 break;
14609
14610 case 2:
14611 222 jx+=32;
14612 222 jy+=32;
14613 222 jdir=11;
14614 222 break;
14615
14616 case 3:
14617 228 jx-=32;
14618 228 jy+=32;
14619 228 jdir=13;
14620 228 break;
14621 }
14622
14623
10/10
✓ Branch 0 taken 893 times.
✓ Branch 1 taken 929 times.
✓ Branch 2 taken 792 times.
✓ Branch 3 taken 101 times.
✓ Branch 4 taken 738 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 638 times.
✓ Branch 7 taken 100 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 122 times.
1822 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
14624 {
14625 516 misc=3;
14626 516 clk3=32;
14627 516 dir=jdir;
14628 516 break;
14629 }
14630 1306 }
14631 [[fallthrough]];
14632 case 3:
14633 1803 dir&=3;
14634 1803 misc=0;
14635 [[fallthrough]];
14636 case 0:
14637 9143 wizzrobe_newdir(64);
14638 [[fallthrough]];
14639 default:
14640
2/2
✓ Branch 0 taken 9772 times.
✓ Branch 1 taken 1039 times.
10811 if(!canmove(dir,(zfix)1,spw_door,false))
14641 {
14642
2/2
✓ Branch 0 taken 990 times.
✓ Branch 1 taken 49 times.
1039 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
14643 {
14644 990 misc=1;
14645 990 clk3=16;
14646 990 }
14647 else
14648 {
14649 49 wizzrobe_newdir(64);
14650 49 misc=0;
14651 49 clk3=32;
14652 }
14653 1039 }
14654 else
14655 {
14656 9772 clk3=32;
14657 }
14658
14659 10811 break;
14660 }
14661
14662
2/2
✓ Branch 0 taken 13382 times.
✓ Branch 1 taken 1465 times.
14847 if(misc<0)
14663 1465 ++misc;
14664 14847 }
14665
14666 380114 --clk3;
14667
14668
3/3
✓ Branch 0 taken 73495 times.
✓ Branch 1 taken 276733 times.
✓ Branch 2 taken 29886 times.
380114 switch(misc)
14669 {
14670 case 1:
14671 case 3:
14672 73495 step=1;
14673 73495 break;
14674
14675 case 2:
14676 29886 step=0;
14677 29886 break;
14678
14679 default:
14680 276733 step=0.5;
14681 276733 break;
14682
14683 }
14684
14685 380114 move(step);
14686
14687 // if(d->misc1 && misc<=0 && clk3==28)
14688
5/6
✓ Branch 0 taken 380114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 276733 times.
✓ Branch 3 taken 103381 times.
✓ Branch 4 taken 267180 times.
✓ Branch 5 taken 9553 times.
380114 if(dmisc1 && misc<=0 && clk3==28)
14689 {
14690
2/2
✓ Branch 0 taken 8105 times.
✓ Branch 1 taken 1448 times.
9553 if(dmisc2 != 1)
14691 {
14692
2/2
✓ Branch 0 taken 7170 times.
✓ Branch 1 taken 935 times.
8105 if(lined_up(8,false) == dir)
14693 {
14694 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
14695 // sfx(WAV_WAND,pan(int32_t(x)));
14696 935 wizzrobe_attack_for_real();
14697 935 fclk=30;
14698 935 }
14699 8105 }
14700 else
14701 {
14702
2/2
✓ Branch 0 taken 1125 times.
✓ Branch 1 taken 323 times.
1448 if((zc_oldrand()%500)>=400)
14703 {
14704 323 wizzrobe_attack_for_real();
14705 323 fclk=30;
14706 323 }
14707 }
14708 9553 }
14709
14710
4/4
✓ Branch 0 taken 243713 times.
✓ Branch 1 taken 136401 times.
✓ Branch 2 taken 1863 times.
✓ Branch 3 taken 241850 times.
380114 if(misc==0 && (zc_oldrand()&127)==0)
14711 1863 misc=2;
14712
14713
4/4
✓ Branch 0 taken 31749 times.
✓ Branch 1 taken 348365 times.
✓ Branch 2 taken 30147 times.
✓ Branch 3 taken 1602 times.
380114 if(misc==2 && clk3==4)
14714 1602 fix_coords();
14715
14716
2/4
✓ Branch 0 taken 380114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 380114 times.
380114 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
14717 {
14718
2/2
✓ Branch 0 taken 344174 times.
✓ Branch 1 taken 35940 times.
380114 if(fclk>0)
14719 {
14720 35940 --fclk;
14721 35940 }
14722 380114 }
14723
14724 401978 }
14725
14726 9505 void eWizzrobe::wizzrobe_newdir(int32_t homing)
14727 {
14728 // Wizzrobes shouldn't move to the edge of the screen;
14729 // if they're already there, they should move toward the center
14730
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 9501 times.
9505 if(x<32)
14731 4 dir=right;
14732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9501 times.
9501 else if(x>=224)
14733 dir=left;
14734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9501 times.
9501 else if(y<32)
14735 dir=down;
14736
1/2
✓ Branch 0 taken 9501 times.
✗ Branch 1 not taken.
9501 else if(y>=144)
14737 dir=up;
14738 else
14739 9501 newdir(4,homing,spw_wizzrobe);
14740 9505 }
14741
14742 831608 void eWizzrobe::draw(BITMAP *dest)
14743 {
14744 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
14745
13/14
✓ Branch 0 taken 408822 times.
✓ Branch 1 taken 422786 times.
✓ Branch 2 taken 348731 times.
✓ Branch 3 taken 60091 times.
✓ Branch 4 taken 39073 times.
✓ Branch 5 taken 369749 times.
✓ Branch 6 taken 38579 times.
✓ Branch 7 taken 494 times.
✓ Branch 8 taken 37822 times.
✓ Branch 9 taken 757 times.
✓ Branch 10 taken 36696 times.
✓ Branch 11 taken 1126 times.
✓ Branch 12 taken 36696 times.
✗ Branch 13 not taken.
831608 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
14746 36696 return;
14747
14748 794912 int32_t tempint=dummy_int[1];
14749 794912 bool tempbool1=dummy_bool[1];
14750 794912 bool tempbool2=dummy_bool[2];
14751 794912 dummy_int[1]=fclk;
14752 794912 dummy_bool[1]=charging;
14753 794912 dummy_bool[2]=firing;
14754 794912 update_enemy_frame();
14755 794912 dummy_int[1]=tempint;
14756 794912 dummy_bool[1]=tempbool1;
14757 794912 dummy_bool[2]=tempbool2;
14758 794912 enemy::draw(dest);
14759 831608 }
14760
14761 /*********************************/
14762 /********** Bosses ***********/
14763 /*********************************/
14764
14765 222 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14766 222 {
14767 111 fading=fade_flash_die;
14768 //nets+5120;
14769
6/8
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26 times.
✓ Branch 7 taken 3 times.
111 if(dir==down&&y>=128)
14770 {
14771 3 dir=up;
14772 3 }
14773
14774
5/8
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
111 if(dir==right&&x>=208)
14775 {
14776 dir=left;
14777 }
14778 111 SIZEflags = d->SIZEflags;
14779
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
111 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14780 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14781 // al_trace("Enemy txsz:%i\n", txsz);
14782
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
111 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14783
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
14784
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
14785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
14786
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
14787
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14788 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14789
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14791 {
14792 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14793 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14794 }
14795
14796
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
111 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
14797 111 }
14798
14799 78920 bool eDodongo::animate(int32_t index)
14800 {
14801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78920 times.
78920 if(switch_hooked) return enemy::animate(index);
14802
2/2
✓ Branch 0 taken 2790 times.
✓ Branch 1 taken 76130 times.
78920 if(dying)
14803 {
14804 2790 return Dead(index);
14805 }
14806
14807
2/2
✓ Branch 0 taken 75788 times.
✓ Branch 1 taken 342 times.
76130 if(clk==0)
14808 {
14809 342 removearmos(x,y,ffcactivated);
14810 342 }
14811
14812
2/2
✓ Branch 0 taken 7104 times.
✓ Branch 1 taken 69026 times.
76130 if(clk2) // ate a bomb
14813 {
14814
2/2
✓ Branch 0 taken 7030 times.
✓ Branch 1 taken 74 times.
7104 if(--clk2==0)
14815 74 hp-=misc; // store bomb's power in misc
14816 7104 }
14817 else
14818 69026 constant_walk(rate,homing,spw_clipright);
14819
14820 76130 hxsz = (dir<=down) ? 16 : 32;
14821 // hysz = (dir>=left) ? 16 : 32;
14822
14823 76130 return enemy::animate(index);
14824 78920 }
14825
14826 78910 void eDodongo::draw(BITMAP *dest)
14827 {
14828 78910 tile=o_tile;
14829
14830
2/2
✓ Branch 0 taken 1833 times.
✓ Branch 1 taken 77077 times.
78910 if(clk<0)
14831 {
14832 1833 enemy::drawzcboss(dest);
14833 1833 return;
14834 }
14835
14836 77077 update_enemy_frame();
14837 77077 enemy::drawzcboss(dest);
14838
14839
2/2
✓ Branch 0 taken 30775 times.
✓ Branch 1 taken 46302 times.
77077 if(dummy_int[1]!=0) //additional tiles
14840 {
14841 46302 tile+=dummy_int[1]; //second tile is previous tile
14842 46302 xofs-=16; //new xofs change
14843 46302 enemy::drawzcboss(dest);
14844 46302 xofs+=16;
14845 46302 }
14846
14847 78910 }
14848
14849 4801 int32_t eDodongo::takehit(weapon *w)
14850 {
14851 4801 int32_t wpnId = w->id;
14852 4801 int32_t power = w->power;
14853 4801 int32_t wpnx = w->x;
14854 4801 int32_t wpny = w->y;
14855
14856
5/12
✓ Branch 0 taken 4801 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4801 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1451 times.
✓ Branch 5 taken 3350 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1451 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4801 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
14857 3350 return 0;
14858
14859
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✓ Branch 2 taken 817 times.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 72 times.
1451 switch(wpnId)
14860 {
14861 case wPhantom:
14862 return 0;
14863
14864 case wFire:
14865 case wBait:
14866 case wWhistle:
14867 case wWind:
14868 case wSSparkle:
14869 case wFSparkle:
14870 return 0;
14871
14872 case wLitBomb:
14873 case wLitSBomb:
14874
6/6
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 371 times.
✓ Branch 2 taken 203 times.
✓ Branch 3 taken 346 times.
✓ Branch 4 taken 475 times.
✓ Branch 5 taken 74 times.
549 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
14875 475 return 0;
14876
14877 74 clk2=96;
14878 74 misc=power;
14879
14880
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 3 times.
74 if(wpnId==wLitSBomb)
14881 3 item_set=isSBOMB100;
14882
14883 74 return 1;
14884
14885 case wBomb:
14886 case wSBomb:
14887
6/6
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 458 times.
✓ Branch 2 taken 257 times.
✓ Branch 3 taken 560 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 500 times.
817 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
14888 317 return 0;
14889
14890 500 stunclk=160;
14891 500 misc=wpnId; // store wpnId
14892 500 return 1;
14893
14894 case wSword:
14895
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 50 times.
72 if(stunclk)
14896 {
14897 50 sfx(WAV_EHIT,pan(int32_t(x)));
14898 50 hp=0;
14899 50 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
14900 50 fading=0; // don't flash
14901 50 return 1;
14902 }
14903
14904 [[fallthrough]];
14905 default:
14906 35 sfx(WAV_CHINK,pan(int32_t(x)));
14907 35 }
14908
14909 35 return 1;
14910 4801 }
14911
14912 4 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14913 4 {
14914 2 fading=fade_flash_die;
14915 //nets+5180;
14916 2 previous_dir=-1;
14917
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==down&&y>=128)
14918 {
14919 dir=up;
14920 }
14921
14922
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==right&&x>=208)
14923 {
14924 dir=left;
14925 }
14926 2 SIZEflags = d->SIZEflags;
14927
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14928 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14929 // al_trace("Enemy txsz:%i\n", txsz);
14930
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14931
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
14932
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
14933
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
14934
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
14935
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14936 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14937
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14939 {
14940 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14941 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14942 }
14943
14944
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
14945 2 }
14946
14947 848 bool eDodongo2::animate(int32_t index)
14948 {
14949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 848 times.
848 if(switch_hooked) return enemy::animate(index);
14950
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 812 times.
848 if(dying)
14951 {
14952 36 return Dead(index);
14953 }
14954
14955
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 4 times.
812 if(clk==0)
14956 {
14957 4 removearmos(x,y,ffcactivated);
14958 4 }
14959
14960
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 620 times.
812 if(clk2) // ate a bomb
14961 {
14962
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 2 times.
192 if(--clk2==0)
14963 2 hp-=misc; // store bomb's power in misc
14964 192 }
14965 else
14966 620 constant_walk(rate,homing,spw_clipbottomright);
14967
14968 812 hxsz = (dir<=down) ? 16 : 32;
14969 812 hysz = (dir>=left) ? 16 : 32;
14970 812 hxofs=(dir>=left)?-8:0;
14971 812 hyofs=(dir<left)?-8:0;
14972
14973 812 return enemy::animate(index);
14974 848 }
14975
14976 848 void eDodongo2::draw(BITMAP *dest)
14977 {
14978
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 818 times.
848 if(clk<0)
14979 {
14980 30 enemy::drawzcboss(dest);
14981 30 return;
14982 }
14983
14984 818 int32_t tempx=xofs;
14985 818 int32_t tempy=yofs;
14986 818 update_enemy_frame();
14987 818 enemy::drawzcboss(dest);
14988 818 tile+=dummy_int[1]; //second tile change
14989 818 xofs+=dummy_int[2]; //new xofs change
14990 818 yofs+=dummy_int[3]; //new yofs change
14991 818 enemy::drawzcboss(dest);
14992 818 xofs=tempx;
14993 818 yofs=tempy;
14994 848 }
14995
14996 165 int32_t eDodongo2::takehit(weapon *w)
14997 {
14998 165 int32_t wpnId = w->id;
14999 165 int32_t power = w->power;
15000 165 int32_t wpnx = w->x;
15001 165 int32_t wpny = w->y;
15002
15003
5/8
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 145 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
165 if(dying || clk<0 || clk2>0 || superman)
15004 145 return 0;
15005
15006
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
20 switch(wpnId)
15007 {
15008 case wPhantom:
15009 return 0;
15010
15011 case wFire:
15012 case wBait:
15013 case wWhistle:
15014 case wWind:
15015 case wSSparkle:
15016 case wFSparkle:
15017 return 0;
15018
15019 case wLitBomb:
15020 case wLitSBomb:
15021
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 switch(dir)
15022 {
15023 case up:
15024 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
15025 return 0;
15026
15027 break;
15028
15029 case down:
15030 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
15031 return 0;
15032
15033 break;
15034
15035 case left:
15036
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
15037 return 0;
15038
15039 2 break;
15040
15041 case right:
15042 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
15043 return 0;
15044
15045 break;
15046 }
15047
15048 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
15049 // return 0;
15050 2 clk2=96;
15051 2 misc=power;
15052
15053
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(wpnId==wLitSBomb)
15054 item_set=isSBOMB100;
15055
15056 2 return 1;
15057
15058 case wBomb:
15059 case wSBomb:
15060
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
15 switch(dir)
15061 {
15062 case up:
15063 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
15064 return 0;
15065
15066 break;
15067
15068 case down:
15069 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
15070 return 0;
15071
15072 break;
15073
15074 case left:
15075
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
15076 return 0;
15077
15078 15 break;
15079
15080 case right:
15081 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
15082 return 0;
15083
15084 break;
15085 }
15086
15087 15 stunclk=160;
15088 15 misc=wpnId; // store wpnId
15089 15 return 1;
15090
15091 case wSword:
15092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(stunclk)
15093 {
15094 2 sfx(WAV_EHIT,pan(int32_t(x)));
15095 2 hp=0;
15096 2 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
15097 2 fading=0; // don't flash
15098 2 return 1;
15099 }
15100
15101 [[fallthrough]];
15102 default:
15103 1 sfx(WAV_CHINK,pan(int32_t(x)));
15104 1 }
15105
15106 1 return 1;
15107 165 }
15108
15109 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
15110 126 {
15111 //these are here to bypass compiler warnings about unused arguments
15112
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if ( !(editorflags & ENEMY_FLAG5) )
15113 {
15114
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 x = dmisc1 ? 64 : 176;
15115
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 y = 64;
15116 63 }
15117 else { x = X; y = Y; }
15118
15119 //nets+5940;
15120
3/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 23 times.
63 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15121 {
15122 40 }
15123 else
15124 {
15125
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(dmisc1)
15126 {
15127 7 flip=1;
15128 7 }
15129 }
15130
15131
3/6
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✓ Branch 4 taken 63 times.
✗ Branch 5 not taken.
63 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
15132 63 clk3=32;
15133 63 clk2=0;
15134 63 clk4=clk;
15135 63 dir=left;
15136 63 SIZEflags = d->SIZEflags;
15137
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
63 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15138 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15139 // al_trace("Enemy txsz:%i\n", txsz);
15140
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
63 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15141
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15142
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15144
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15145
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15146 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15149 {
15150 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15151 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15152 }
15153
15154
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15155 63 }
15156
15157 40754 bool eAquamentus::animate(int32_t index)
15158 {
15159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40754 times.
40754 if(switch_hooked) return enemy::animate(index);
15160
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 39710 times.
40754 if(dying)
15161 1044 return Dead(index);
15162
15163 // fbx=x+((id==eRAQUAM)?4:-4);
15164
2/2
✓ Branch 0 taken 39532 times.
✓ Branch 1 taken 178 times.
39710 if(clk==0)
15165 {
15166 178 removearmos(x,y,ffcactivated);
15167 178 }
15168
15169 39710 fbx=x;
15170
15171 /*
15172 if (get_bit(quest_rules,qr_NEWENEMYTILES)&&id==eLAQUAM)
15173 {
15174 fbx+=16;
15175 }
15176 */
15177
2/2
✓ Branch 0 taken 39456 times.
✓ Branch 1 taken 254 times.
39710 if(--clk3==0)
15178 {
15179 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
15180 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
15181 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
15182 254 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
15183 254 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
15184 254 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
15185 254 sfx(wpnsfx(wpn),pan(int32_t(x)));
15186 254 }
15187
15188
4/4
✓ Branch 0 taken 12207 times.
✓ Branch 1 taken 27503 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 12007 times.
39710 if(clk3<-80 && !(zc_oldrand()&63))
15189 {
15190 200 clk3=32;
15191 200 }
15192
15193
2/2
✓ Branch 0 taken 39077 times.
✓ Branch 1 taken 633 times.
39710 if(!((clk4+1)&63))
15194 {
15195 633 int32_t d2=(zc_oldrand()%3)+1;
15196
15197
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 432 times.
633 if(d2>=left)
15198 {
15199 432 dir=d2;
15200 432 }
15201
15202
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 291 times.
633 if(dmisc1)
15203 {
15204
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 34 times.
342 if(x<=40)
15205 {
15206 34 dir=right;
15207 34 }
15208
15209
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 if(x>=104)
15210 {
15211 dir=left;
15212 }
15213 342 }
15214 else
15215 {
15216
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 7 times.
291 if(x<=136)
15217 {
15218 7 dir=right;
15219 7 }
15220
15221
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 14 times.
291 if(x>=200)
15222 {
15223 14 dir=left;
15224 14 }
15225 }
15226 633 }
15227
15228
4/4
✓ Branch 0 taken 38781 times.
✓ Branch 1 taken 929 times.
✓ Branch 2 taken 33906 times.
✓ Branch 3 taken 4875 times.
39710 if(clk4>=-1 && !((clk4+1)&7))
15229 {
15230
2/2
✓ Branch 0 taken 2553 times.
✓ Branch 1 taken 2322 times.
4875 if(dir==left)
15231 {
15232 2553 x-=1;
15233 2553 }
15234 else
15235 {
15236 2322 x+=1;
15237 }
15238 4875 }
15239
15240 39710 clk4=(clk4+1)%256;
15241
15242 39710 return enemy::animate(index);
15243 40754 }
15244
15245 41165 void eAquamentus::draw(BITMAP *dest)
15246 {
15247
2/2
✓ Branch 0 taken 25711 times.
✓ Branch 1 taken 15454 times.
41165 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15248 {
15249 25711 xofs=(dmisc1?-16:0);
15250
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25711 times.
✓ Branch 2 taken 10660 times.
✓ Branch 3 taken 15051 times.
25711 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
15251
15252
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 25063 times.
25711 if(dying)
15253 {
15254 648 xofs=0;
15255 648 enemy::draw(dest);
15256 648 }
15257 else
15258 {
15259 25063 drawblock(dest,15);
15260 }
15261 25711 }
15262 else
15263 {
15264 15454 int32_t xblockofs=((dmisc1)?-16:16);
15265 15454 xofs=0;
15266
15267
4/4
✓ Branch 0 taken 15109 times.
✓ Branch 1 taken 345 times.
✓ Branch 2 taken 396 times.
✓ Branch 3 taken 14713 times.
15454 if(clk<0 || dying)
15268 {
15269 741 enemy::draw(dest);
15270 741 return;
15271 }
15272
1/2
✓ Branch 0 taken 14713 times.
✗ Branch 1 not taken.
14713 if ( do_animation )
15273 {
15274 // face (0=firing, 2=resting)
15275 14713 tile=o_tile+((clk3>0)?0:2);
15276 14713 enemy::draw(dest);
15277 // tail (
15278 14713 tile=o_tile+((clk&16)?1:3);
15279 14713 xofs=xblockofs;
15280 14713 enemy::draw(dest);
15281 // body
15282 14713 yofs+=16;
15283 14713 xofs=0;
15284 14713 tile=o_tile+((clk&16)?20:22);
15285 14713 enemy::draw(dest);
15286 14713 xofs=xblockofs;
15287 14713 tile=o_tile+((clk&16)?21:23);
15288 14713 enemy::draw(dest);
15289 14713 yofs-=16;
15290 14713 }
15291 else enemy::draw(dest);
15292 }
15293 41165 }
15294
15295 8292 bool eAquamentus::hit(weapon *w)
15296 {
15297
3/6
✓ Branch 0 taken 8292 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8292 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8292 times.
8292 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk) return false;
15298
15299
2/2
✓ Branch 0 taken 2698 times.
✓ Branch 1 taken 5594 times.
8292 switch(w->id)
15300 {
15301 case wBeam:
15302 case wRefBeam:
15303 case wMagic:
15304 2698 hysz=32;
15305 2698 }
15306
15307
4/4
✓ Branch 0 taken 8171 times.
✓ Branch 1 taken 121 times.
✓ Branch 2 taken 6234 times.
✓ Branch 3 taken 1937 times.
8292 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
15308 8292 hysz=16;
15309 8292 return ret;
15310
15311 8292 }
15312
15313 88 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
15314 88 {
15315
15316
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if ( !(editorflags & ENEMY_FLAG5) )
15317 {
15318
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 x = 128;
15319
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 y = 48;
15320 44 }
15321 else { x = X; y = Y; }
15322
15323 44 Clk=Clk;
15324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(flags & guy_fadeflicker)
15325 {
15326 clk=0;
15327 superman = 1;
15328 fading=fade_flicker;
15329 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
15330 }
15331
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 36 times.
44 else if(flags & guy_fadeinstant)
15332 {
15333 36 clk=0;
15334 36 }
15335 44 hxofs=-16;
15336 44 hxsz=48;
15337 44 clk4=0;
15338
3/6
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
44 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
15339
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 dir=zc_oldrand()%3+1;
15340 44 SIZEflags = d->SIZEflags;
15341
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15342 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15343 // al_trace("Enemy txsz:%i\n", txsz);
15344
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
15345
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
15346
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
15347
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
15348
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
15349
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
15350 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15351
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
15352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15353 {
15354 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
15355 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15356 }
15357
15358
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
15359
15360 //nets+5340;
15361 44 }
15362
15363 41378 bool eGohma::animate(int32_t index)
15364 {
15365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41378 times.
41378 if(switch_hooked) return enemy::animate(index);
15366
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 40802 times.
41378 if(dying)
15367 576 return Dead(index);
15368
15369
1/2
✓ Branch 0 taken 40802 times.
✗ Branch 1 not taken.
40802 if(fading)
15370 {
15371 if(++clk4 > 60)
15372 {
15373 clk4=0;
15374 superman=0;
15375 fading=0;
15376 clk=0;
15377
15378 }
15379 else return enemy::animate(index);
15380 }
15381
15382
2/2
✓ Branch 0 taken 40622 times.
✓ Branch 1 taken 180 times.
40802 if(clk==0)
15383 {
15384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if (ffcactivated) removearmosffc(ffcactivated-1);
15385 else
15386 {
15387
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 removearmos(zc_max(x-16, zfix(0)),y);
15388 180 did_armos = false;
15389 180 removearmos(x,y);
15390 180 did_armos = false;
15391
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 removearmos(zc_min(x+16, zfix(255)),y);
15392 }
15393 180 }
15394
15395
2/2
✓ Branch 0 taken 40682 times.
✓ Branch 1 taken 120 times.
40802 if(clk<0) return enemy::animate(index);
15396
15397 // Movement clk must be separate from animation clk because of the Clock item
15398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40682 times.
40682 if(!watch)
15399 40682 clk4++;
15400
15401
2/2
✓ Branch 0 taken 40067 times.
✓ Branch 1 taken 615 times.
40682 if((clk4&63)==0)
15402 {
15403
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 295 times.
615 if(clk4&64)
15404 320 dir^=1;
15405 else
15406 295 dir=zc_oldrand()%3+1;
15407 615 }
15408
15409
2/2
✓ Branch 0 taken 40026 times.
✓ Branch 1 taken 656 times.
40682 if((clk&63)==3)
15410 {
15411
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 187 times.
656 switch(dmisc1)
15412 {
15413 case 1:
15414 187 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
15415 187 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
15416 187 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
15417 187 sfx(wpnsfx(wpn),pan(int32_t(x)));
15418 187 break;
15419
15420 default:
15421
3/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 384 times.
469 if(dmisc1 != 1 && dmisc1 != 2)
15422 {
15423 384 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
15424 384 sfx(wpnsfx(wpn),pan(int32_t(x)));
15425 384 sfx(wpnsfx(wpn),pan(int32_t(x)));
15426 384 }
15427
15428 469 break;
15429 }
15430 656 }
15431
15432
6/6
✓ Branch 0 taken 5356 times.
✓ Branch 1 taken 35326 times.
✓ Branch 2 taken 5084 times.
✓ Branch 3 taken 272 times.
✓ Branch 4 taken 3692 times.
✓ Branch 5 taken 1392 times.
40682 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
15433 {
15434
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 1209 times.
1392 if(!(clk3%8))
15435 {
15436 183 FireBreath(true);
15437 183 }
15438 1392 }
15439
15440
2/2
✓ Branch 0 taken 20331 times.
✓ Branch 1 taken 20351 times.
40682 if(clk4&1)
15441 20351 move((zfix)1);
15442
15443
2/2
✓ Branch 0 taken 40591 times.
✓ Branch 1 taken 91 times.
40682 if(++clk3>=400)
15444 91 clk3=0;
15445
15446 40682 return enemy::animate(index);
15447 41378 }
15448
15449 41376 void eGohma::draw(BITMAP *dest)
15450 {
15451 41376 tile=o_tile;
15452
15453
4/4
✓ Branch 0 taken 41256 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 40680 times.
41376 if(clk<0 || dying)
15454 {
15455 696 enemy::drawzcboss(dest);
15456 696 return;
15457 }
15458
15459
2/2
✓ Branch 0 taken 33103 times.
✓ Branch 1 taken 7577 times.
40680 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15460 {
15461 ///if ( do_animation )
15462 //Yuck. Gohma can just not have this capability right now.
15463 // left side
15464 33103 xofs=-16;
15465 33103 flip=0;
15466 // if(clk&16) tile=180;
15467 // else { tile=182; flip=1; }
15468 33103 tile+=(3*((clk&48)>>4));
15469 33103 enemy::drawzcboss(dest);
15470
15471 // right side
15472 33103 xofs=16;
15473 // tile=(180+182)-tile;
15474 33103 tile=o_tile;
15475 33103 tile+=(3*((clk&48)>>4))+2;
15476 33103 enemy::drawzcboss(dest);
15477
15478 // body
15479 33103 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
15480 33103 tile=o_tile;
15481
15482 // tile+=(3*((clk&24)>>3))+2;
15483
2/2
✓ Branch 0 taken 1743 times.
✓ Branch 1 taken 31360 times.
33103 if(clk3<16)
15484 1743 tile+=7;
15485
2/2
✓ Branch 0 taken 9362 times.
✓ Branch 1 taken 21998 times.
31360 else if(clk3<116)
15486 9362 tile+=10;
15487
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 20683 times.
21998 else if(clk3<132)
15488 1315 tile+=7;
15489 else
15490 20683 tile+=((clk3-132)&24)?4:1;
15491
15492 33103 enemy::drawzcboss(dest);
15493
15494 33103 }
15495 else
15496 {
15497 // left side
15498 7577 xofs=-16;
15499 7577 flip=0;
15500
15501
2/2
✓ Branch 0 taken 3750 times.
✓ Branch 1 taken 3827 times.
7577 if(!(clk&16))
15502 {
15503 3827 tile+=2;
15504 3827 flip=1;
15505 3827 }
15506
15507 7577 enemy::draw(dest);
15508
15509 // right side
15510 7577 tile=o_tile;
15511 7577 xofs=16;
15512
15513
2/2
✓ Branch 0 taken 3827 times.
✓ Branch 1 taken 3750 times.
7577 if((clk&16)) tile+=2;
15514
15515 // tile=(180+182)-tile;
15516 7577 enemy::draw(dest);
15517
15518 // body
15519 7577 tile=o_tile;
15520 7577 xofs=0;
15521
15522
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 7161 times.
7577 if(clk3<16)
15523 416 tile+=4;
15524
2/2
✓ Branch 0 taken 2279 times.
✓ Branch 1 taken 4882 times.
7161 else if(clk3<116)
15525 2279 tile+=5;
15526
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 4585 times.
4882 else if(clk3<132)
15527 297 tile+=4;
15528 4585 else tile+=((clk3-132)&8)?3:1;
15529
15530 7577 enemy::draw(dest);
15531
15532 }
15533 41376 }
15534
15535 203 int32_t eGohma::takehit(weapon *w)
15536 {
15537 203 int32_t wpnId = w->id;
15538 203 int32_t power = w->power;
15539 203 int32_t wpnx = w->x;
15540 203 int32_t wpnDir = w->dir;
15541 203 int32_t def = defenditemclassNew(wpnId, &power, w);
15542
15543
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 92 times.
203 if(def < 0)
15544 {
15545
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 67 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 59 times.
✓ Branch 9 taken 8 times.
92 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
15546 {
15547 33 sfx(WAV_CHINK,pan(int32_t(x)));
15548 33 return 1;
15549 }
15550 59 }
15551
15552 170 return enemy::takehit(w);
15553 203 }
15554
15555 354 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15556 354 {
15557 177 count_enemy=(id==(id&0xFFF));
15558 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
15559 177 SIZEflags = d->SIZEflags;
15560
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
177 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15561 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15562 // al_trace("Enemy txsz:%i\n", txsz);
15563
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
177 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15564
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15565
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15567
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15568
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15569 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15570
1/4
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
177 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15572 {
15573 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15574 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15575 }
15576
15577
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15578 177 }
15579
15580 63881 bool eLilDig::animate(int32_t index)
15581 {
15582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63881 times.
63881 if(switch_hooked) return enemy::animate(index);
15583
2/2
✓ Branch 0 taken 2646 times.
✓ Branch 1 taken 61235 times.
63881 if(dying)
15584 2646 return Dead(index);
15585
15586
2/2
✓ Branch 0 taken 3228 times.
✓ Branch 1 taken 58007 times.
61235 if(clk==0)
15587 {
15588 3228 removearmos(x,y,ffcactivated);
15589 3228 }
15590
15591
2/2
✓ Branch 0 taken 40187 times.
✓ Branch 1 taken 21048 times.
61235 if(misc<=128)
15592 {
15593
2/2
✓ Branch 0 taken 633 times.
✓ Branch 1 taken 20415 times.
21048 if(!(++misc&31))
15594 633 step+=0.25;
15595 21048 }
15596
15597 61235 variable_walk_8(rate,homing,hrate,spw_floater);
15598 61235 return enemy::animate(index);
15599 63881 }
15600
15601 63749 void eLilDig::draw(BITMAP *dest)
15602 {
15603 63749 tile = o_tile;
15604 // tile = 160;
15605 63749 int32_t fdiv = frate/4;
15606
1/2
✓ Branch 0 taken 63749 times.
✗ Branch 1 not taken.
63749 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15607
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 17438 times.
63749 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
15608 63749 efrate:((clk>=(frate>>1))?1:0);
15609
15610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63749 times.
63749 if ( do_animation )
15611 {
15612
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 17438 times.
63749 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15613 {
15614
9/9
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 5465 times.
✓ Branch 2 taken 5245 times.
✓ Branch 3 taken 5717 times.
✓ Branch 4 taken 5242 times.
✓ Branch 5 taken 4505 times.
✓ Branch 6 taken 3937 times.
✓ Branch 7 taken 5035 times.
✓ Branch 8 taken 5312 times.
46311 switch(dir-8) //directions get screwed up after 8. *shrug*
15615 {
15616 case up: //u
15617 5853 flip=0;
15618 5853 break;
15619
15620 case l_up: //d
15621 5465 flip=0;
15622 5465 tile+=4;
15623 5465 break;
15624
15625 case l_down: //l
15626 5245 flip=0;
15627 5245 tile+=8;
15628 5245 break;
15629
15630 case left: //r
15631 5717 flip=0;
15632 5717 tile+=12;
15633 5717 break;
15634
15635 case r_down: //ul
15636 5242 flip=0;
15637 5242 tile+=20;
15638 5242 break;
15639
15640 case down: //ur
15641 4505 flip=0;
15642 4505 tile+=24;
15643 4505 break;
15644
15645 case r_up: //dl
15646 3937 flip=0;
15647 3937 tile+=28;
15648 3937 break;
15649
15650 case right: //dr
15651 5035 flip=0;
15652 5035 tile+=32;
15653 5035 break;
15654 }
15655
15656 46311 tile+=f2;
15657 46311 }
15658 else
15659 {
15660 17438 tile+=(clk>=6)?1:0;
15661 }
15662 63749 }
15663
15664 63749 enemy::draw(dest);
15665 63749 }
15666
15667 76 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15668 76 {
15669 38 superman=1;
15670
15671 38 SIZEflags = d->SIZEflags;
15672
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15673 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15674 // al_trace("Enemy txsz:%i\n", txsz);
15675
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15676
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15677 38 else hxsz=32;
15678
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15679 38 else hysz=32;
15680
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15681 38 else hzsz=16; // hard to jump.
15682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15683 38 else hxofs=-8;
15684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15685 38 else hyofs=-8;
15686 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15687
1/4
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15689 {
15690 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15691 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15692 }
15693
15694
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15695
15696
15697 38 }
15698
15699 14929 bool eBigDig::animate(int32_t index)
15700 {
15701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14929 times.
14929 if(switch_hooked) return enemy::animate(index);
15702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14929 times.
14929 if(dying)
15703 return Dead(index);
15704
15705
2/2
✓ Branch 0 taken 12960 times.
✓ Branch 1 taken 1969 times.
14929 if(clk==0)
15706 {
15707 1969 removearmos(x,y,ffcactivated);
15708 1969 }
15709
15710
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14859 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 35 times.
14929 switch(misc)
15711 {
15712 case 0:
15713 14859 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
15714 14859 break;
15715
15716 case 1:
15717 35 ++misc;
15718 35 break;
15719
15720 case 2:
15721
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 35 times.
137 for(int32_t i=0; i<dmisc5; i++)
15722 {
15723 102 addenemy(x,y,dmisc1+0x1000,-15);
15724 102 }
15725
15726
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 35 times.
45 for(int32_t i=0; i<dmisc6; i++)
15727 {
15728 10 addenemy(x,y,dmisc2+0x1000,-15);
15729 10 }
15730
15731
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 35 times.
45 for(int32_t i=0; i<dmisc7; i++)
15732 {
15733 10 addenemy(x,y,dmisc3+0x1000,-15);
15734 10 }
15735
15736
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 35 times.
45 for(int32_t i=0; i<dmisc8; i++)
15737 {
15738 10 addenemy(x,y,dmisc4+0x1000,-15);
15739 10 }
15740
15741
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(itemguy) // Hand down the carried item
15742 {
15743 guycarryingitem = guys.Count()-1;
15744 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
15745 itemguy = false;
15746 }
15747
15748 35 stop_bgsfx(index);
15749
15750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
15751
15752 35 return true;
15753 }
15754
15755 14894 return enemy::animate(index);
15756 14929 }
15757
15758 14924 void eBigDig::draw(BITMAP *dest)
15759 {
15760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14924 times.
14924 if(anim!=aDIG)
15761 {
15762 update_enemy_frame();
15763 xofs-=8;
15764 yofs-=8;
15765 drawblock(dest,15);
15766 xofs+=8;
15767 yofs+=8;
15768 return;
15769 }
15770
15771 14924 tile = o_tile;
15772 14924 int32_t fdiv = frate/4;
15773
1/2
✓ Branch 0 taken 14924 times.
✗ Branch 1 not taken.
14924 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15774
15775
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 4686 times.
14924 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
15776 14924 efrate:((clk>=(frate>>1))?1:0);
15777
15778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14924 times.
14924 if ( do_animation )
15779 {
15780
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 4686 times.
14924 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15781 {
15782
9/9
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 1195 times.
✓ Branch 4 taken 1233 times.
✓ Branch 5 taken 1223 times.
✓ Branch 6 taken 993 times.
✓ Branch 7 taken 1450 times.
✓ Branch 8 taken 464 times.
10238 switch(dir-8) //directions get screwed up after 8. *shrug*
15783 {
15784 case up: //u
15785 1115 flip=0;
15786 1115 break;
15787
15788 case l_up: //d
15789 1221 flip=0;
15790 1221 tile+=8;
15791 1221 break;
15792
15793 case l_down: //l
15794 1344 flip=0;
15795 1344 tile+=40;
15796 1344 break;
15797
15798 case left: //r
15799 1195 flip=0;
15800 1195 tile+=48;
15801 1195 break;
15802
15803 case r_down: //ul
15804 1233 flip=0;
15805 1233 tile+=80;
15806 1233 break;
15807
15808 case down: //ur
15809 1223 flip=0;
15810 1223 tile+=88;
15811
15812 1223 break;
15813
15814 case r_up: //dl
15815 993 flip=0;
15816 993 tile+=120;
15817 993 break;
15818
15819 case right: //dr
15820 1450 flip=0;
15821 1450 tile+=128;
15822 1450 break;
15823 }
15824
15825 10238 tile+=(f2*2);
15826 10238 }
15827 else
15828 {
15829 4686 tile+=(f2)?0:2;
15830 4686 flip=(clk&1)?1:0;
15831 }
15832 14924 }
15833
15834 14924 xofs-=8;
15835 14924 yofs-=8;
15836 14924 drawblock(dest,15);
15837 14924 xofs+=8;
15838 14924 yofs+=8;
15839 14924 }
15840
15841 269 int32_t eBigDig::takehit(weapon *w)
15842 {
15843 269 int32_t wpnId = w->id;
15844
15845
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
269 if(wpnId==wWhistle && misc==0)
15846 35 misc=1;
15847
15848 269 return 0;
15849 }
15850
15851 /*
15852 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15853 {
15854 hxofs=hyofs=8;
15855 hzsz=16; //can't be jumped.
15856 clk2=70;
15857 misc=-1;
15858 mainguy=!getmapflag();
15859 }
15860
15861 bool eGanon::animate(int32_t index)
15862 {
15863 if(switch_hooked) return enemy::animate(index);
15864 if(dying)
15865
15866 return Dead(index);
15867
15868 if(clk==0)
15869 {
15870 removearmos(x,y,ffcactivated);
15871 }
15872
15873 switch(misc)
15874 {
15875 case -1:
15876 misc=0;
15877
15878 case 0:
15879 if(++clk2>72 && !(zc_oldrand()&3))
15880 {
15881 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
15882 sfx(wpnsfx(wpn),pan(int32_t(x)));
15883 clk2=0;
15884 }
15885
15886 Stunclk=0;
15887 constant_walk(rate,homing,spw_none);
15888 break;
15889
15890 case 1:
15891 case 2:
15892 if(--Stunclk<=0)
15893 {
15894 int32_t r=zc_oldrand();
15895
15896 if(r&1)
15897 {
15898 y=96;
15899
15900 if(r&2)
15901 x=160;
15902 else
15903 x=48;
15904
15905 if(tooclose(x,y,48))
15906 x=208-x;
15907 }
15908
15909 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
15910 //{
15911 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
15912 // }
15913 // else
15914 // {
15915 loadpalset(csBOSS,pSprite(d->bosspal));
15916 // }
15917 misc=0;
15918 }
15919
15920 break;
15921
15922 case 3:
15923 {
15924 if(hclk>0)
15925 break;
15926
15927 misc=4;
15928 clk=0;
15929 hxofs=1000;
15930 loadpalset(9,pSprite(spPILE));
15931 music_stop();
15932 stop_sfx(WAV_ROAR);
15933
15934 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
15935
15936 sfx(WAV_GANON);
15937 //Ganon's dustpile; fall in sideview. -Z
15938 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
15939 dustpile->linked_parent = eeGANON;
15940 setmapflag();
15941 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
15942 break;
15943 }
15944
15945 case 4:
15946 if(clk>=80)
15947 {
15948 misc=5;
15949
15950 if(getmapflag())
15951 {
15952 game->lvlitems[dlevel]|=liBOSS;
15953 //play_DmapMusic();
15954 playLevelMusic();
15955 return true;
15956 }
15957
15958 sfx(WAV_CLEARED);
15959 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
15960 setmapflag();
15961 }
15962
15963 break;
15964 }
15965
15966 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
15967 //{
15968 //if ( current_item_id(itype_amulet,false) >= 2 )
15969 //{
15970 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
15971 //}
15972 //}
15973
15974
15975 return enemy::animate(index);
15976 }
15977
15978
15979 int32_t eGanon::takehit(weapon *w)
15980 {
15981 //these are here to bypass compiler warnings about unused arguments
15982 int32_t wpnId = w->id;
15983 int32_t power = w->power;
15984 int32_t enemyHitWeapon = w->parentitem;
15985
15986 switch(misc)
15987 {
15988 case 0:
15989 {
15990 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
15991 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
15992 return 0;
15993
15994 //if we are not using the new defences, just reduce his HP
15995 if (!(editorflags & ENEMY_FLAG14))
15996 {
15997 hp-=power;
15998 if(hp>0)
15999 {
16000 misc=1;
16001 Stunclk=64;
16002 }
16003 else
16004 {
16005 loadpalset(csBOSS,pSprite(spBROWN));
16006 misc=2;
16007 Stunclk=284;
16008 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
16009 }
16010
16011 sfx(WAV_EHIT,pan(int32_t(x)));
16012
16013 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
16014
16015 return 1;
16016 }
16017 //otherwise, resolve his defence.
16018 else
16019 {
16020 int32_t def = enemy::takehit(w); //This works, but it instantly kills him if it does enough damage.
16021 if(hp>0)
16022 {
16023 misc=1;
16024 Stunclk=64;
16025 }
16026 else
16027 {
16028 loadpalset(csBOSS,pSprite(spBROWN));
16029 misc=2;
16030 Stunclk=284;
16031 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
16032 }
16033
16034 sfx(WAV_EHIT,pan(int32_t(x)));
16035
16036 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
16037
16038
16039 return 1;
16040 }
16041 }
16042 case 2:
16043 {
16044 if
16045 (
16046 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
16047 || //or nothing specified, use silver arrows+
16048 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
16049 )
16050 return 0;
16051 {
16052 misc=3;
16053 hclk=81;
16054 loadpalset(9,pSprite(spBROWN));
16055 return 1;
16056 }
16057
16058 }
16059 }
16060
16061 return 0;
16062 }
16063
16064 void eGanon::draw(BITMAP *dest)
16065 {
16066 switch(misc)
16067 {
16068 case 0:
16069 if((clk&3)==3)
16070 tile=(zc_oldrand()%5)*2+o_tile;
16071
16072 if(db!=999)
16073 break;
16074
16075 case 2:
16076 if(Stunclk<64 && (Stunclk&1) )
16077 {
16078 if
16079 (
16080 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
16081 ||
16082 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
16083 )
16084 {
16085 goto ganon_draw; //draw his weapons if we can see him
16086 }
16087 break;
16088 }
16089
16090 case -1:
16091 tile=o_tile;
16092
16093 //fall through
16094 case 1:
16095 case 3:
16096 ganon_draw:
16097 drawblock(dest,15);
16098 break;
16099
16100 case 4:
16101 draw_guts(dest);
16102 draw_flash(dest);
16103 break;
16104 }
16105
16106 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
16107 {
16108 if
16109 (
16110 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
16111 ||
16112 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
16113 )
16114 {
16115 draw_guts(dest); //makes his shots visible, but not him
16116 draw_flash(dest);
16117 }
16118 }
16119 }
16120
16121 void eGanon::draw_guts(BITMAP *dest)
16122 {
16123 int32_t c = zc_min(clk>>3,8);
16124 tile = clk<24 ? 74 : 75;
16125 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
16126 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
16127 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
16128 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
16129 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
16130 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
16131 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
16132 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
16133 }
16134
16135 void eGanon::draw_flash(BITMAP *dest)
16136 {
16137
16138 int32_t c = clk-(clk>>2);
16139 cs = (frame&3)+6;
16140 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
16141 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
16142 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
16143 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
16144 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
16145 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
16146 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
16147 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
16148 }
16149 */
16150
16151 12 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16152 12 {
16153 6 hxofs=hyofs=8;
16154
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (editorflags & ENEMY_FLAG3)
16155 {
16156 hxofs = 4;
16157 hyofs = 4;
16158 hxsz = 24;
16159 hysz = 24;
16160 SIZEflags|=guyflagOVERRIDE_HIT_WIDTH;
16161 SIZEflags|=guyflagOVERRIDE_HIT_HEIGHT;
16162 }
16163 6 hzsz=16; //can't be jumped.
16164 6 clk2=70;
16165 6 misc=-1;
16166
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
6 mainguy=(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
16167 6 }
16168
16169 9583 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
16170 {
16171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9583 times.
9583 if(dying)
16172
16173 return Dead(index);
16174
16175
2/2
✓ Branch 0 taken 9546 times.
✓ Branch 1 taken 37 times.
9583 if(clk==0)
16176 {
16177 37 removearmos(x,y,ffcactivated);
16178 37 }
16179
16180
6/7
✓ Branch 0 taken 1754 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6847 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 492 times.
✓ Branch 5 taken 480 times.
✓ Branch 6 taken 4 times.
9583 switch(misc)
16181 {
16182 case -1:
16183 6 misc=0;
16184 [[fallthrough]];
16185 case 0:
16186
4/4
✓ Branch 0 taken 373 times.
✓ Branch 1 taken 6480 times.
✓ Branch 2 taken 279 times.
✓ Branch 3 taken 94 times.
6853 if(++clk2>72 && !(zc_oldrand()&3))
16187 {
16188 94 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16189 94 sfx(wpnsfx(wpn),pan(int32_t(x)));
16190 94 clk2=0;
16191 94 }
16192
16193 6853 Stunclk=0;
16194 6853 constant_walk(rate,homing,spw_none);
16195 6853 break;
16196
16197 case 1:
16198 case 2:
16199
2/2
✓ Branch 0 taken 1733 times.
✓ Branch 1 taken 21 times.
1754 if(--Stunclk<=0)
16200 {
16201 21 int32_t r=zc_oldrand();
16202
16203
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 9 times.
21 if(r&1)
16204 {
16205 9 y=96;
16206
16207
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7 times.
9 if(r&2)
16208 2 x=160;
16209 else
16210 7 x=48;
16211
16212
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
9 if(tooclose(x,y,48))
16213 2 x=208-x;
16214 9 }
16215
16216 21 loadpalset(csBOSS,pSprite(d->bosspal));
16217 21 misc=0;
16218 21 }
16219
16220 1754 break;
16221
16222 case 3:
16223 {
16224
2/2
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 6 times.
492 if(hclk>0)
16225 486 break;
16226
16227 6 misc=4;
16228 6 clk=0;
16229 6 hxofs=1000;
16230 6 loadpalset(9,pSprite(spPILE));
16231 6 music_stop();
16232 6 stop_sfx(WAV_ROAR);
16233
16234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
16235
16236 6 sfx(WAV_GANON);
16237 //Ganon's dustpile; fall in sideview. -Z
16238 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
16239 //dustpile->miscellaneous[31] = eeGANON;
16240
6/12
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
6 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
16241 6 item *dustpile = NULL;
16242 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
16243 6 dustpile = (item *)items.spr(items.Count() - 1);
16244 6 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
16245 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
16246 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
16247 6 break;
16248 }
16249
16250 case 4:
16251
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 6 times.
480 if(clk>=80)
16252 {
16253 6 misc=5;
16254
16255 //game->lvlitems[dlevel]|=liBOSS;
16256
16257 6 sfx(WAV_CLEARED);
16258 //Add the big TF over the ashes!
16259
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 for(word q = 0; q < items.Count(); q++)
16260 {
16261 12 item *ashes = (item*)items.spr(q);
16262
3/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
12 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
16263 {
16264 //Z_scripterrlog("Found correct dustpile!\n");
16265
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
6 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
16266 6 item *bigtriforce = NULL;
16267 6 bigtriforce = (item *)items.spr(items.Count() - 1);
16268 6 bigtriforce->linked_parent = eeGANON;
16269 6 }
16270 12 }
16271 //setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
16272 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
16273 6 }
16274
16275 480 break;
16276 4 case 5: return true;
16277 }
16278
16279 9579 return enemy::animate(index);
16280 9583 }
16281
16282
16283 524 int32_t eGanon::takehit(weapon *w)
16284 {
16285 //these are here to bypass compiler warnings about unused arguments
16286 524 int32_t wpnId = w->id;
16287 524 int32_t power = w->power;
16288 524 int32_t enemyHitWeapon = w->parentitem;
16289
16290
3/3
✓ Branch 0 taken 426 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 71 times.
524 switch(misc)
16291 {
16292 case 0:
16293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(wpnId!=wSword)
16294 return 0;
16295
16296 27 hp-=power;
16297
16298
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 6 times.
27 if(hp>0)
16299 {
16300 21 misc=1;
16301 21 Stunclk=64;
16302 21 }
16303 else
16304 {
16305 6 loadpalset(csBOSS,pSprite(spBROWN));
16306 6 misc=2;
16307 6 Stunclk=284;
16308 6 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
16309 }
16310
16311 27 sfx(WAV_EHIT,pan(int32_t(x)));
16312
16313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
16314
16315 27 return 1;
16316
16317 case 2:
16318
4/6
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
71 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
16319 65 return 0;
16320
16321 6 misc=3;
16322 6 hclk=81;
16323 6 loadpalset(9,pSprite(spBROWN));
16324 6 return 1;
16325 }
16326
16327 426 return 0;
16328 524 }
16329
16330 10747 void eGanon::draw(BITMAP *dest)
16331 {
16332
6/6
✓ Branch 0 taken 1836 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 410 times.
✓ Branch 3 taken 1170 times.
✓ Branch 4 taken 6847 times.
✓ Branch 5 taken 480 times.
10747 switch(misc)
16333 {
16334 case 0:
16335
2/2
✓ Branch 0 taken 5135 times.
✓ Branch 1 taken 1712 times.
6847 if((clk&3)==3)
16336 1712 tile=(zc_oldrand()%5)*2+o_tile;
16337
16338
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6847 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6847 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
16339 {
16340
16341 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
16342 {
16343 int odraw = drawstyle;
16344 drawstyle = 2;
16345 drawblock(dest,15);
16346 drawstyle = odraw;
16347 }
16348 else
16349 {
16350 drawblock(dest,15);
16351 }
16352 break;
16353
16354 }
16355
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6847 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6847 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
16356 {
16357 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
16358 {
16359 int odraw = drawstyle;
16360 drawstyle = 2;
16361 drawblock(dest,15);
16362 drawstyle = odraw;
16363 }
16364 else
16365 {
16366 drawblock(dest,15);
16367 }
16368 break;
16369 }
16370
1/2
✓ Branch 0 taken 6847 times.
✗ Branch 1 not taken.
6847 if(db!=999)
16371 6847 break;
16372 [[fallthrough]];
16373 case 2:
16374
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
410 if(Stunclk<64 && (Stunclk&1))
16375 break;
16376 [[fallthrough]];
16377 case -1:
16378 1580 tile=o_tile;
16379
16380 [[fallthrough]];
16381 case 1:
16382 case 3:
16383 3416 drawblock(dest,15);
16384 3416 break;
16385
16386 case 4:
16387 480 draw_guts(dest);
16388 480 draw_flash(dest);
16389 480 break;
16390 }
16391 10747 }
16392
16393 480 void eGanon::draw_guts(BITMAP *dest)
16394 {
16395
2/2
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 102 times.
480 int32_t c = zc_min(clk>>3,8);
16396 480 tile = clk<24 ? 74 : 75;
16397 480 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
16398 480 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
16399 480 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
16400 480 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
16401 480 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
16402 480 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
16403 480 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
16404 480 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
16405 480 }
16406
16407 480 void eGanon::draw_flash(BITMAP *dest)
16408 {
16409
16410 480 int32_t c = clk-(clk>>2);
16411 480 cs = (frame&3)+6;
16412 480 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
16413 480 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
16414 480 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
16415 480 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
16416 480 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
16417 480 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
16418 480 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
16419 480 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
16420 480 }
16421
16422 6 void getBigTri(int32_t id2)
16423 {
16424 /*
16425 *************************
16426 * BIG TRIFORCE SEQUENCE *
16427 *************************
16428 0 BIGTRI out, WHITE flash in
16429 4 WHITE flash out, PILE cset white
16430 8 WHITE in
16431 ...
16432 188 WHITE out
16433 191 PILE cset red
16434 200 top SHUTTER opens
16435 209 bottom SHUTTER opens
16436 */
16437 6 sfx(itemsbuf[id2].playsound);
16438 6 guys.clear();
16439
16440
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
16441 {
16442 game->lvlitems[dlevel]|=liTRIFORCE;
16443 }
16444
16445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
16446
16447 6 draw_screen(tmpscr);
16448
16449
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1152 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1152 times.
1158 for(int32_t f=0; f<24*8 && !Quit; f++)
16450 {
16451
2/2
✓ Branch 0 taken 1146 times.
✓ Branch 1 taken 6 times.
1152 if(f==4)
16452 {
16453
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6 times.
96 for(int32_t i=1; i<16; i++)
16454 {
16455 90 RAMpal[CSET(9)+i]=_RGB(63,63,63);
16456 90 }
16457 6 }
16458
16459
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 144 times.
1152 if((f&7)==0)
16460 {
16461
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 144 times.
576 for(int32_t cs=2; cs<5; cs++)
16462 {
16463
2/2
✓ Branch 0 taken 6480 times.
✓ Branch 1 taken 432 times.
6912 for(int32_t i=1; i<16; i++)
16464 {
16465 6480 RAMpal[CSET(cs)+i]=_RGB(63,63,63);
16466 6480 }
16467 432 }
16468
16469 144 refreshpal=true;
16470 144 }
16471
16472
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 144 times.
1152 if((f&7)==4)
16473 {
16474
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
16475 else loadlvlpal(0xB);
16476 144 }
16477
16478
2/2
✓ Branch 0 taken 1146 times.
✓ Branch 1 taken 6 times.
1152 if(f==191)
16479 {
16480 6 loadpalset(9,pSprite(spPILE));
16481 6 }
16482
16483 1152 advanceframe(true);
16484 1152 }
16485
16486 //play_DmapMusic();
16487 6 playLevelMusic();
16488
16489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(itemsbuf[id2].flags & ITEM_FLAG1 && currscr < 128)
16490 {
16491 Hero.dowarp(1,0); //side warp
16492 }
16493 6 }
16494
16495 /**********************************/
16496 /*** Multiple-Segment Enemies ***/
16497 /**********************************/
16498
16499
16500 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
16501 156 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16502 156 {
16503
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if( !(editorflags & ENEMY_FLAG5) )
16504 {
16505
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 x=128;
16506
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 y=48;
16507 78 }
16508 //else { x = X; y = Y; }
16509
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 dir=(zc_oldrand()&7)+8;
16510 78 superman=1;
16511 78 fading=fade_invisible;
16512 78 hxofs=1000;
16513 78 segcnt=clk;
16514 78 segid=Id|0x1000;
16515 78 clk=0;
16516
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 id=guys.Count();
16517
3/6
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
✓ Branch 4 taken 78 times.
✗ Branch 5 not taken.
78 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16518 78 tile=o_tile;
16519 78 hitdir = -1;
16520 78 stickclk = 0;
16521
16522 /*
16523 if (get_bit(quest_rules,qr_NEWENEMYTILES))
16524 {
16525 tile=nets+1220;
16526 }
16527 else
16528 {
16529 tile=57;
16530 }
16531 */
16532 78 }
16533
16534 75195 bool eMoldorm::animate(int32_t index)
16535 {
16536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75195 times.
75195 if(switch_hooked) return enemy::animate(index);
16537 75195 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
16538
2/2
✓ Branch 0 taken 58230 times.
✓ Branch 1 taken 16965 times.
75195 if ( y > (max_y) )
16539 {
16540 16965 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
16541 //Z_scripterrlog("Stickclk is %d\n", stickclk);
16542 16965 }
16543
2/2
✓ Branch 0 taken 74846 times.
✓ Branch 1 taken 349 times.
75195 if ( stickclk > 45 )
16544 {
16545 349 stickclk = 0;
16546 349 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
16547 349 }
16548
16549
16550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75195 times.
75195 if(clk==0)
16551 {
16552 75195 removearmos(x,y,ffcactivated);
16553 75195 }
16554
16555
2/2
✓ Branch 0 taken 950 times.
✓ Branch 1 taken 74245 times.
75195 if(clk2)
16556 {
16557
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 50 times.
950 if(--clk2 == 0)
16558 {
16559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(flags&guy_neverret)
16560 50 never_return(index);
16561
16562
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
16563 50 leave_item();
16564
16565 50 stop_bgsfx(index);
16566 50 return true;
16567 }
16568 900 }
16569 else
16570 {
16571
1/2
✓ Branch 0 taken 74245 times.
✗ Branch 1 not taken.
74245 if(stunclk>0)
16572 stunclk=0;
16573 74245 constant_walk_8_old(rate,homing,spw_floater);
16574
16575
16576 74245 misc=dir;
16577
16578 // If any higher-numbered segments were killed, segcnt can be too high,
16579 // leading to a crash
16580
1/2
✓ Branch 0 taken 74245 times.
✗ Branch 1 not taken.
74245 if(index+segcnt>=guys.Count())
16581 segcnt=guys.Count()-index-1;
16582
16583
2/2
✓ Branch 0 taken 74245 times.
✓ Branch 1 taken 415023 times.
489268 for(int32_t i=index+1; i<index+segcnt+1; i++)
16584 {
16585 415023 enemy* segment=((enemy*)guys.spr(i));
16586
16587 // More validation - if segcnt was wrong, this may not
16588 // actually be a Moldorm segment
16589
1/2
✓ Branch 0 taken 415023 times.
✗ Branch 1 not taken.
415023 if(segment->id!=segid)
16590 {
16591 segcnt=i-index-1;
16592 break;
16593 }
16594
16595
2/2
✓ Branch 0 taken 340711 times.
✓ Branch 1 taken 74312 times.
415023 if(i==index+1)
16596 {
16597 74312 x=segment->x;
16598 74312 y=segment->y;
16599 74312 }
16600
16601 415023 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
16602 //Script your own blasted segmented bosses!! -Z
16603 415023 segment->parent_script_UID = this->script_UID;
16604
4/4
✓ Branch 0 taken 74245 times.
✓ Branch 1 taken 340778 times.
✓ Branch 2 taken 10161 times.
✓ Branch 3 taken 64084 times.
415023 if((i==index+segcnt)&&(i!=index+1)) //tail
16605 {
16606 64084 segment->dummy_int[1]=2;
16607 64084 }
16608 else
16609 {
16610 350939 segment->dummy_int[1]=1;
16611 }
16612
16613
2/2
✓ Branch 0 taken 340711 times.
✓ Branch 1 taken 74312 times.
415023 if(i==index+1) //head
16614 {
16615 74312 segment->dummy_int[1]=0;
16616 74312 }
16617
16618
2/2
✓ Branch 0 taken 414703 times.
✓ Branch 1 taken 320 times.
415023 if(segment->hp <= 0)
16619 {
16620 320 int32_t offset=1;
16621
16622
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 532 times.
852 for(int32_t j=i; j<index+segcnt; j++)
16623 {
16624 // Triple-check
16625
1/2
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
532 if(((enemy*)guys.spr(j+1))->id!=segid)
16626 {
16627 segcnt=j-index+1; // Add 1 because of --segcnt below
16628 break;
16629 }
16630 532 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
16631 532 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
16632 532 }
16633
16634 320 segment->hclk=33;
16635 320 --segcnt;
16636 320 --i; // Recheck the same index in case multiple segments died at once
16637 320 }
16638 415023 }
16639
16640
2/2
✓ Branch 0 taken 74195 times.
✓ Branch 1 taken 50 times.
74245 if(segcnt==0)
16641 {
16642 50 clk2=19;
16643
16644 50 x=guys.spr(index+1)->x;
16645 50 y=guys.spr(index+1)->y;
16646 50 }
16647 }
16648
16649 75145 return false;
16650 75195 }
16651
16652 900 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16653 900 {
16654
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if( !(editorflags & ENEMY_FLAG5) )
16655 {
16656
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 x=128;
16657
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 y=48;
16658 450 }
16659
16660
3/6
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 450 times.
✓ Branch 4 taken 450 times.
✗ Branch 5 not taken.
450 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16661 450 hyofs=4;
16662 450 hxsz=hysz=8;
16663 450 hxofs=1000;
16664 450 mainguy=count_enemy=false;
16665 450 parentclk = 0;
16666 450 bgsfx=-1;
16667 450 flags&=~guy_neverret;
16668 //deadsfx = WAV_EDEAD;
16669 450 isCore = false;
16670 450 }
16671
16672 420783 bool esMoldorm::animate(int32_t index)
16673 {
16674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 420783 times.
420783 if(switch_hooked) return enemy::animate(index);
16675 // Shouldn't be possible, but better to be sure
16676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 420783 times.
420783 if(index==0)
16677 dying=true;
16678
16679
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 415023 times.
420783 if(dying)
16680 {
16681
1/2
✓ Branch 0 taken 5760 times.
✗ Branch 1 not taken.
5760 if(!dmisc2)
16682 5760 item_set=0;
16683
16684 5760 return Dead(index);
16685 }
16686
16687
2/2
✓ Branch 0 taken 19478 times.
✓ Branch 1 taken 395545 times.
415023 if(clk>=0)
16688 {
16689 395545 hxofs=4;
16690 395545 step=((enemy*)guys.spr(index-1))->step;
16691
16692
2/2
✓ Branch 0 taken 30349 times.
✓ Branch 1 taken 365196 times.
395545 if(parentclk == 0)
16693 {
16694 30349 misc=dir;
16695 30349 dir=((enemy*)guys.spr(index-1))->misc;
16696 //do alignment, as in parent's animation :-/ -DD
16697 30349 x.doFloor();
16698 30349 y.doFloor();
16699 30349 }
16700
16701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395545 times.
395545 if(step)
16702 395545 parentclk=(parentclk+1)%((int32_t)(8.0/step));
16703
16704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395545 times.
395545 if(!watch)
16705 {
16706 395545 sprite::move(step);
16707 395545 }
16708 395545 }
16709
16710 415023 return enemy::animate(index);
16711 420783 }
16712
16713 1599 int32_t esMoldorm::takehit(weapon *w)
16714 {
16715
2/2
✓ Branch 0 taken 1452 times.
✓ Branch 1 taken 147 times.
1599 if(enemy::takehit(w))
16716 1452 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
16717
16718 147 return 0;
16719 1599 }
16720
16721 422733 void esMoldorm::draw(BITMAP *dest)
16722 {
16723 422733 tile=o_tile;
16724 422733 int32_t fdiv = frate/4;
16725
1/2
✓ Branch 0 taken 422733 times.
✗ Branch 1 not taken.
422733 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
16726
16727
2/2
✓ Branch 0 taken 361156 times.
✓ Branch 1 taken 61577 times.
422733 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
16728 422733 efrate:((clk>=(frate>>1))?1:0);
16729
16730
2/2
✓ Branch 0 taken 61577 times.
✓ Branch 1 taken 361156 times.
422733 if(get_bit(quest_rules,qr_NEWENEMYTILES))
16731 {
16732 361156 tile+=dummy_int[1]*40;
16733
16734
2/2
✓ Branch 0 taken 16310 times.
✓ Branch 1 taken 344846 times.
361156 if(dir<8)
16735 {
16736 16310 flip=0;
16737
2/2
✓ Branch 0 taken 12412 times.
✓ Branch 1 taken 3898 times.
16310 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
16738
16739
1/2
✓ Branch 0 taken 16310 times.
✗ Branch 1 not taken.
16310 if(dir>3) // Skip to the next row for diagonals
16740 tile+=4;
16741 16310 }
16742 else
16743 {
16744
8/9
✓ Branch 0 taken 37639 times.
✓ Branch 1 taken 47584 times.
✓ Branch 2 taken 38450 times.
✓ Branch 3 taken 47147 times.
✓ Branch 4 taken 39397 times.
✓ Branch 5 taken 38189 times.
✓ Branch 6 taken 46292 times.
✓ Branch 7 taken 50148 times.
✗ Branch 8 not taken.
344846 switch(dir-8) //directions get screwed up after 8. *shrug*
16745 {
16746 case up: //u
16747 37639 flip=0;
16748 37639 break;
16749
16750 case l_up: //d
16751 47584 flip=0;
16752 47584 tile+=4;
16753 47584 break;
16754
16755 case l_down: //l
16756 38450 flip=0;
16757 38450 tile+=8;
16758 38450 break;
16759
16760 case left: //r
16761 47147 flip=0;
16762 47147 tile+=12;
16763 47147 break;
16764
16765 case r_down: //ul
16766 39397 flip=0;
16767 39397 tile+=20;
16768 39397 break;
16769
16770 case down: //ur
16771 38189 flip=0;
16772 38189 tile+=24;
16773 38189 break;
16774
16775 case r_up: //dl
16776 46292 flip=0;
16777 46292 tile+=28;
16778 46292 break;
16779
16780 case right: //dr
16781 50148 flip=0;
16782 50148 tile+=32;
16783 50148 break;
16784 }
16785 }
16786
16787 361156 tile+=f2;
16788 361156 }
16789
16790
2/2
✓ Branch 0 taken 19532 times.
✓ Branch 1 taken 403201 times.
422733 if(clk>=0)
16791 403201 enemy::draw(dest);
16792 422733 }
16793
16794 180 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
16795 180 {
16796
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if( !(editorflags & ENEMY_FLAG5) )
16797 {
16798
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 x=64;
16799
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 y=80;
16800 90 }
16801 //else { x = X; y = Y; }
16802 //zprint2("lanmola index is %d\n", index);
16803 //byte legaldirs = 0;
16804 90 int32_t incr = 16;
16805 //int32_t possiiblepos = 0;
16806 //int32_t positions[8] = {0};
16807
16808 //Don't spawn in pits.
16809
5/8
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✓ Branch 7 taken 2 times.
90 if ( m_walkflag_simple(x, y) )
16810 {
16811 //zprint2("Can't spawn here.\n");
16812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for ( ; incr < 240; incr += 16 )
16813 {
16814 //move if we spawn over a pit
16815 //check each direction
16816
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
2 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
16817 {
16818 //zprint2("Spawn adjustment: -x (%d)\n", incr);
16819
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 x-=incr; break;
16820 }
16821 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
16822 {
16823 //zprint2("Spawn adjustment: +x (%d)\n", incr);
16824 x+=incr; break;
16825 }
16826 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
16827 {
16828 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
16829 x-=incr; y-=incr; break;
16830 }
16831 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
16832 {
16833 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
16834 x+=incr; y-=incr; break;
16835 }
16836 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
16837 {
16838 //zprint2("Spawn adjustment: -y (%d)\n", incr);
16839 y -= incr; break;
16840 }
16841 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
16842 {
16843 //zprint2("Spawn adjustment: +y (%d)\n", incr);
16844 y+=incr; break;
16845 }
16846 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
16847 {
16848 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
16849 x-=incr; y+=incr; break;
16850 }
16851 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
16852 {
16853 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
16854 x+=incr; y+=incr; break;
16855 }
16856 else continue;
16857
16858 }
16859
16860 2 }
16861
16862 90 dir=up;
16863 90 superman=1;
16864 90 fading=fade_invisible;
16865 90 hxofs=1000;
16866 90 segcnt=clk;
16867 90 clk=0;
16868 //set up move history
16869
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 778 times.
868 for(int32_t i=0; i <= (1<<dmisc2); i++)
16870
3/6
✓ Branch 0 taken 778 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 778 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 778 times.
✗ Branch 5 not taken.
778 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
16871 90 }
16872
16873 87883 bool eLanmola::animate(int32_t index)
16874 {
16875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87883 times.
87883 if(switch_hooked) return enemy::animate(index);
16876
2/2
✓ Branch 0 taken 75385 times.
✓ Branch 1 taken 12498 times.
87883 if(clk==0)
16877 {
16878 12498 removearmos(x,y,ffcactivated);
16879 12498 }
16880
16881
2/2
✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 86420 times.
87883 if(clk2)
16882 {
16883
2/2
✓ Branch 0 taken 1386 times.
✓ Branch 1 taken 77 times.
1463 if(--clk2 == 0)
16884 {
16885
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 20 times.
77 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
16886 57 leave_item();
16887
16888 77 stop_bgsfx(index);
16889 77 return true;
16890 }
16891
16892 1386 return false;
16893 }
16894
16895
16896 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
16897 //the direction AND x,y position of the lanmola to vary in uncertain ways.
16898 //I've added a complete movement history to this enemy to compensate -DD
16899 86420 constant_walk(rate,homing,spw_none);
16900 86420 prevState.pop_front();
16901 86420 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
16902
16903 // This could cause a crash with Moldorms. I didn't see the same problem
16904 // with Lanmolas, but it looks like it ought to be possible, so here's
16905 // the same solution. - Saf
16906
1/2
✓ Branch 0 taken 86420 times.
✗ Branch 1 not taken.
86420 if(index+segcnt>=guys.Count())
16907 segcnt=guys.Count()-index-1;
16908
16909
2/2
✓ Branch 0 taken 86420 times.
✓ Branch 1 taken 401833 times.
488253 for(int32_t i=index+1; i<index+segcnt+1; i++)
16910 {
16911 401833 enemy* segment=((enemy*)guys.spr(i));
16912
16913 // More validation in case segcnt is wrong
16914
1/2
✓ Branch 0 taken 401833 times.
✗ Branch 1 not taken.
401833 if((segment->id&0xFFF)!=(id&0xFFF))
16915 {
16916 segcnt=i-index-1;
16917 break;
16918 }
16919
16920 401833 segment->o_tile=o_tile;
16921 401833 segment->parent_script_UID = this->script_UID;
16922
4/4
✓ Branch 0 taken 86420 times.
✓ Branch 1 taken 315413 times.
✓ Branch 2 taken 16001 times.
✓ Branch 3 taken 70419 times.
401833 if((i==index+segcnt)&&(i!=index+1))
16923 {
16924 70419 segment->dummy_int[1]=1; //tail
16925 70419 }
16926 else
16927 {
16928 331414 segment->dummy_int[1]=0;
16929 }
16930
16931
2/2
✓ Branch 0 taken 401382 times.
✓ Branch 1 taken 451 times.
401833 if(segment->hp <= 0)
16932 {
16933
2/2
✓ Branch 0 taken 451 times.
✓ Branch 1 taken 811 times.
1262 for(int32_t j=i; j<index+segcnt; j++)
16934 {
16935 // Triple-check
16936
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
16937 {
16938 segcnt=j-index+1; // Add 1 because of --segcnt below
16939 break;
16940 }
16941 811 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
16942 811 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
16943 811 }
16944
16945 451 ((enemy*)guys.spr(i))->hclk=33;
16946 451 --segcnt;
16947 451 --i; // Recheck the same index in case multiple segments died at once
16948 451 }
16949 401833 }
16950
16951
2/2
✓ Branch 0 taken 86343 times.
✓ Branch 1 taken 77 times.
86420 if(segcnt==0)
16952 {
16953 77 clk2=19;
16954 77 x=guys.spr(index+1)->x;
16955 77 y=guys.spr(index+1)->y;
16956 77 setmapflag(mTMPNORET);
16957 77 }
16958
16959 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
16960 //which is... disastrous.
16961 86420 hp = 1;
16962 86420 return enemy::animate(index);
16963 87883 }
16964
16965 1010 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
16966 1010 {
16967
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if( !(editorflags & ENEMY_FLAG5) )
16968 {
16969
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 x=64;
16970
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 y=80;
16971 505 }
16972 505 int32_t incr = 16;
16973 //Don't spawn in pits.
16974
5/8
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 505 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 505 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 495 times.
✓ Branch 7 taken 10 times.
505 if ( m_walkflag_simple(x, y) )
16975 {
16976 //zprint2("Can't spawn here.\n");
16977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 for ( ; incr < 240; incr += 16 )
16978 {
16979 //move if we spawn over a pit
16980 //check each direction
16981
6/12
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10 times.
✗ Branch 11 not taken.
10 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
16982 {
16983 //zprint2("Spawn adjustment: -x (%d)\n", incr);
16984
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 x-=incr; break;
16985 }
16986 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
16987 {
16988 //zprint2("Spawn adjustment: +x (%d)\n", incr);
16989 x+=incr; break;
16990 }
16991 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
16992 {
16993 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
16994 x-=incr; y-=incr; break;
16995 }
16996 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
16997 {
16998 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
16999 x+=incr; y-=incr; break;
17000 }
17001 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
17002 {
17003 //zprint2("Spawn adjustment: -y (%d)\n", incr);
17004 y -= incr; break;
17005 }
17006 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
17007 {
17008 //zprint2("Spawn adjustment: +y (%d)\n", incr);
17009 y+=incr; break;
17010 }
17011 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
17012 {
17013 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
17014 x-=incr; y+=incr; break;
17015 }
17016 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
17017 {
17018 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
17019 x+=incr; y+=incr; break;
17020 }
17021 else continue;
17022
17023 }
17024
17025 10 }
17026
17027 505 hxofs=1000;
17028 505 hxsz=8;
17029 505 mainguy=false;
17030 505 count_enemy=(id<0x2000)?true:false;
17031
17032 //set up move history
17033
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 4345 times.
4850 for(int32_t i=0; i <= (1<<dmisc2); i++)
17034
3/6
✓ Branch 0 taken 4345 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4345 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4345 times.
✗ Branch 5 not taken.
4345 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
17035
17036 505 bgsfx = -1;
17037 505 isCore = false;
17038 505 flags&=~guy_neverret;
17039 505 }
17040
17041 409951 bool esLanmola::animate(int32_t index)
17042 {
17043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409951 times.
409951 if(switch_hooked) return enemy::animate(index);
17044 // Shouldn't be possible, but who knows
17045
1/2
✓ Branch 0 taken 409951 times.
✗ Branch 1 not taken.
409951 if(index==0)
17046 dying=true;
17047
17048
2/2
✓ Branch 0 taken 8118 times.
✓ Branch 1 taken 401833 times.
409951 if(dying)
17049 {
17050 8118 xofs=0;
17051
17052
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 6318 times.
8118 if(!dmisc3)
17053 6318 item_set=0;
17054
17055 8118 return Dead(index);
17056 }
17057
17058
2/2
✓ Branch 0 taken 11680 times.
✓ Branch 1 taken 390153 times.
401833 if(clk>=0)
17059 {
17060 390153 hxofs=4;
17061
17062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390153 times.
390153 if(!watch)
17063 {
17064 390153 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
17065 390153 prevState.pop_front();
17066 390153 prevState.push_back(newstate);
17067 390153 x = newstate.first.first;
17068 390153 y = newstate.first.second;
17069 390153 dir = newstate.second;
17070 390153 }
17071 390153 }
17072
17073 401833 return enemy::animate(index);
17074 409951 }
17075
17076 1324 int32_t esLanmola::takehit(weapon *w)
17077 {
17078
2/2
✓ Branch 0 taken 1208 times.
✓ Branch 1 taken 116 times.
1324 if(enemy::takehit(w))
17079 1208 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
17080
17081 116 return 0;
17082 1324 }
17083
17084 411232 void esLanmola::draw(BITMAP *dest)
17085 {
17086 411232 tile=o_tile;
17087 411232 int32_t fdiv = frate/4;
17088
1/2
✓ Branch 0 taken 411232 times.
✗ Branch 1 not taken.
411232 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17089
17090
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 73699 times.
411232 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17091 411232 efrate:((clk>=(frate>>1))?1:0);
17092
17093
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 73699 times.
411232 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17094 {
17095
2/2
✓ Branch 0 taken 68269 times.
✓ Branch 1 taken 269264 times.
337533 if(id>=0x2000)
17096 {
17097 269264 tile+=20;
17098
17099
2/2
✓ Branch 0 taken 209782 times.
✓ Branch 1 taken 59482 times.
269264 if(dummy_int[1]==1)
17100 {
17101 59482 tile+=20;
17102 59482 }
17103 269264 }
17104
17105
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 70158 times.
✓ Branch 2 taken 71956 times.
✓ Branch 3 taken 93557 times.
✓ Branch 4 taken 101862 times.
337533 switch(dir)
17106 {
17107 case up:
17108 70158 flip=0;
17109 70158 break;
17110
17111 case down:
17112 71956 flip=0;
17113 71956 tile+=4;
17114 71956 break;
17115
17116 case left:
17117 93557 flip=0;
17118 93557 tile+=8;
17119 93557 break;
17120
17121 case right:
17122 101862 flip=0;
17123 101862 tile+=12;
17124 101862 break;
17125 }
17126
17127 337533 tile+=f2;
17128 337533 }
17129 else
17130 {
17131
2/2
✓ Branch 0 taken 20051 times.
✓ Branch 1 taken 53648 times.
73699 if(id>=0x2000)
17132 {
17133 53648 tile+=1;
17134 53648 }
17135 }
17136
17137
2/2
✓ Branch 0 taken 11680 times.
✓ Branch 1 taken 399552 times.
411232 if(clk>=0)
17138 399552 enemy::draw(dest);
17139 411232 }
17140
17141 108 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
17142 108 {
17143 //these are here to bypass compiler warnings about unused arguments
17144 54 Clk=Clk;
17145 54 superman=1;
17146
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 dir=(zc_oldrand()&7)+8;
17147 54 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
17148
17149
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 54 times.
302 for(int32_t i=0; i<armcnt; i++)
17150 248 arm[i]=i;
17151
17152 54 fading=fade_blue_poof;
17153 //nets+4680;
17154 54 adjusted=false;
17155 54 SIZEflags = d->SIZEflags; //Probably will be buggy. -Z 12 AUG 2020
17156
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17157 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17158 // al_trace("Enemy txsz:%i\n", txsz);
17159
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17160
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
17161
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
17162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17163
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17164
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17165 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17166
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
17167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17168 {
17169 yofs = d->yofs+(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17170 }
17171
17172
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
17173 54 }
17174
17175 28824 bool eManhandla::animate(int32_t index)
17176 {
17177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28824 times.
28824 if(switch_hooked) return enemy::animate(index);
17178
2/2
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 28122 times.
28824 if(dying)
17179 702 return Dead(index);
17180
17181
2/2
✓ Branch 0 taken 26926 times.
✓ Branch 1 taken 1196 times.
28122 if(clk==0)
17182 {
17183 1196 removearmos(x,y,ffcactivated);
17184 1196 }
17185
17186
17187 // check arm status, move dead ones to end of group
17188
2/2
✓ Branch 0 taken 88458 times.
✓ Branch 1 taken 28122 times.
116580 for(int32_t i=0; i<armcnt; i++)
17189 {
17190 88458 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
17191
3/4
✓ Branch 0 taken 88458 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 188 times.
✓ Branch 3 taken 88270 times.
88458 if(!cur_arm || cur_arm->dying)
17192 {
17193
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 188 times.
423 for(int32_t j=i; j<armcnt-1; j++)
17194 {
17195 235 zc_swap(arm[j],arm[j+1]);
17196 235 guys.swap(index+j+1,index+j+2);
17197 235 }
17198
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 20 times.
188 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
17199 {
17200 20 leave_item();
17201 20 }
17202 188 --armcnt;
17203 188 --i;
17204 188 continue;
17205 }
17206
2/2
✓ Branch 0 taken 88022 times.
✓ Branch 1 taken 248 times.
88270 if(!adjusted)
17207 {
17208
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 64 times.
248 if(!dmisc2)
17209 {
17210 184 cur_arm->o_tile=o_tile+40;
17211 184 cur_arm->parent_script_UID = this->script_UID;
17212 184 }
17213 else
17214 {
17215 64 cur_arm->o_tile=o_tile+160;
17216 64 cur_arm->parent_script_UID = this->script_UID;
17217 }
17218 248 }
17219 88270 }
17220
17221 28122 adjusted=true;
17222
17223 // move or die
17224
2/2
✓ Branch 0 taken 28083 times.
✓ Branch 1 taken 39 times.
28122 if(armcnt==0)
17225 39 hp=0;
17226 else
17227 {
17228 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
17229
1/2
✓ Branch 0 taken 28083 times.
✗ Branch 1 not taken.
28083 step=zc_min(zfix(4.5),(((!dmisc2)?4:8)-int64_t(armcnt))*0.5+zslongToFix(dstep*100));
17230 28083 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
17231
17232
2/2
✓ Branch 0 taken 25202 times.
✓ Branch 1 taken 2881 times.
28083 if(!dmisc2)
17233 {
17234
2/2
✓ Branch 0 taken 74283 times.
✓ Branch 1 taken 25202 times.
99485 for(int32_t i=0; i<armcnt; i++)
17235 {
17236
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 17558 times.
✓ Branch 2 taken 19867 times.
✓ Branch 3 taken 18200 times.
✓ Branch 4 taken 18658 times.
74283 switch(arm[i])
17237 {
17238 case 0:
17239 17558 dy1=-24;
17240 17558 break;
17241
17242 case 1:
17243 19867 dy2=31;
17244 19867 break;
17245
17246 case 2:
17247 18200 dx1=-16;
17248 18200 break;
17249
17250 case 3:
17251 18658 dx2=31;
17252 18658 break;
17253 }
17254 74283 }
17255 25202 }
17256 else
17257 {
17258 2881 dx1=-8, dy1=-16, dx2=23, dy2=23;
17259
17260
2/2
✓ Branch 0 taken 13987 times.
✓ Branch 1 taken 2881 times.
16868 for(int32_t i=0; i<armcnt; i++)
17261 {
17262
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4279 times.
✓ Branch 2 taken 3184 times.
✓ Branch 3 taken 2549 times.
✓ Branch 4 taken 3975 times.
13987 switch(arm[i]&3)
17263 {
17264 case 0:
17265 4279 dy1=-32;
17266 4279 break;
17267
17268 case 1:
17269 3184 dy2=39;
17270 3184 break;
17271
17272 case 2:
17273 2549 dx1=-24;
17274 2549 break;
17275
17276 case 3:
17277 3975 dx2=39;
17278 3975 break;
17279 }
17280 13987 }
17281 }
17282
17283 28083 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
17284
17285
2/2
✓ Branch 0 taken 88270 times.
✓ Branch 1 taken 28083 times.
116353 for(int32_t i=0; i<armcnt; i++)
17286 {
17287 88270 zfix dx=(zfix)0,dy=(zfix)0;
17288
17289
2/2
✓ Branch 0 taken 74283 times.
✓ Branch 1 taken 13987 times.
88270 if(!dmisc2)
17290 {
17291
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 17558 times.
✓ Branch 2 taken 19867 times.
✓ Branch 3 taken 18200 times.
✓ Branch 4 taken 18658 times.
74283 switch(arm[i])
17292 {
17293 case 0:
17294 17558 dy=-16;
17295 17558 break;
17296
17297 case 1:
17298 19867 dy=16;
17299 19867 break;
17300
17301 case 2:
17302 18200 dx=-16;
17303 18200 break;
17304
17305 case 3:
17306 18658 dx=16;
17307 18658 break;
17308 }
17309 74283 }
17310 else
17311 {
17312
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
✓ Branch 2 taken 1789 times.
✓ Branch 3 taken 1292 times.
✓ Branch 4 taken 2015 times.
✓ Branch 5 taken 2599 times.
✓ Branch 6 taken 1395 times.
✓ Branch 7 taken 1257 times.
✓ Branch 8 taken 1960 times.
13987 switch(arm[i])
17313 {
17314 case 0:
17315 1680 dy=-24;
17316 1680 dx=-8;
17317 1680 break;
17318
17319 case 1:
17320 1789 dy=24;
17321 1789 dx=8;
17322 1789 break;
17323
17324 case 2:
17325 1292 dx=-24;
17326 1292 dy=8;
17327 1292 break;
17328
17329 case 3:
17330 2015 dx=24;
17331 2015 dy=-8;
17332 2015 break;
17333
17334 case 4:
17335 2599 dy=-24;
17336 2599 dx=8;
17337 2599 break;
17338
17339 case 5:
17340 1395 dy=24;
17341 1395 dx=-8;
17342 1395 break;
17343
17344 case 6:
17345 1257 dx=-24;
17346 1257 dy=-8;
17347 1257 break;
17348
17349 case 7:
17350 1960 dx=24;
17351 1960 dy=8;
17352 1960 break;
17353 }
17354 }
17355
17356 88270 guys.spr(index+i+1)->x = x+dx;
17357 88270 guys.spr(index+i+1)->y = y+dy;
17358 88270 }
17359 }
17360
17361 28122 return enemy::animate(index);
17362 28824 }
17363
17364
17365 1232 int32_t eManhandla::takehit(weapon *w)
17366 {
17367 1232 int32_t wpnId = w->id;
17368
17369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1232 times.
1232 if(dying)
17370 return 0;
17371
17372
3/4
✓ Branch 0 taken 799 times.
✓ Branch 1 taken 417 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
1232 switch(wpnId)
17373 {
17374 case wBomb:
17375 case wSBomb:
17376 case wSword:
17377 case wHammer:
17378 case wWand:
17379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417 times.
417 if (get_bit(quest_rules, qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
17380
17381 case wLitBomb:
17382 case wLitSBomb:
17383 case wBait:
17384 case wWhistle:
17385 case wFire:
17386 case wWind:
17387 case wSSparkle:
17388 case wFSparkle:
17389 case wPhantom:
17390 1216 return 0;
17391
17392 case wHookshot:
17393 case wBrang:
17394 sfx(WAV_CHINK,pan(int32_t(x)));
17395 break;
17396
17397 default:
17398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (get_bit(quest_rules, qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
17399 else sfx(WAV_CHINK,pan(int32_t(x)));
17400
17401 16 }
17402
17403 16 return 1;
17404 1232 }
17405
17406 28822 void eManhandla::draw(BITMAP *dest)
17407 {
17408 28822 tile=o_tile;
17409 28822 int32_t fdiv = frate/4;
17410
1/2
✓ Branch 0 taken 28822 times.
✗ Branch 1 not taken.
28822 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17411
17412
2/2
✓ Branch 0 taken 21250 times.
✓ Branch 1 taken 7572 times.
28822 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17413 28822 efrate:((clk>=(frate>>1))?1:0);
17414
17415
2/2
✓ Branch 0 taken 21250 times.
✓ Branch 1 taken 7572 times.
28822 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17416 {
17417
2/2
✓ Branch 0 taken 2518 times.
✓ Branch 1 taken 18732 times.
21250 if(!dmisc2)
17418 {
17419
8/9
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 2084 times.
✓ Branch 2 taken 2751 times.
✓ Branch 3 taken 2878 times.
✓ Branch 4 taken 1783 times.
✓ Branch 5 taken 1846 times.
✓ Branch 6 taken 1929 times.
✓ Branch 7 taken 3061 times.
✗ Branch 8 not taken.
18732 switch(dir-8) //directions get screwed up after 8. *shrug*
17420 {
17421 case up: //u
17422 2400 flip=0;
17423 2400 break;
17424
17425 case l_up: //d
17426 2084 flip=0;
17427 2084 tile+=4;
17428 2084 break;
17429
17430 case l_down: //l
17431 2751 flip=0;
17432 2751 tile+=8;
17433 2751 break;
17434
17435 case left: //r
17436 2878 flip=0;
17437 2878 tile+=12;
17438 2878 break;
17439
17440 case r_down: //ul
17441 1783 flip=0;
17442 1783 tile+=20;
17443 1783 break;
17444
17445 case down: //ur
17446 1846 flip=0;
17447 1846 tile+=24;
17448 1846 break;
17449
17450 case r_up: //dl
17451 1929 flip=0;
17452 1929 tile+=28;
17453 1929 break;
17454
17455 case right: //dr
17456 3061 flip=0;
17457 3061 tile+=32;
17458 3061 break;
17459 }
17460
17461 18732 tile+=f2;
17462 18732 enemy::draw(dest);
17463 18732 } //manhandla 2, big body
17464 else
17465 {
17466
17467
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
✓ Branch 2 taken 483 times.
✓ Branch 3 taken 500 times.
✓ Branch 4 taken 315 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 215 times.
✓ Branch 7 taken 164 times.
✓ Branch 8 taken 288 times.
2518 switch(dir-8) //directions get screwed up after 8. *shrug*
17468 {
17469 case up: //u
17470 357 flip=0;
17471 357 break;
17472
17473 case l_up: //d
17474 483 flip=0;
17475 483 tile+=8;
17476 483 break;
17477
17478 case l_down: //l
17479 500 flip=0;
17480 500 tile+=40;
17481 500 break;
17482
17483 case left: //r
17484 315 flip=0;
17485 315 tile+=48;
17486 315 break;
17487
17488 case r_down: //ul
17489 196 flip=0;
17490 196 tile+=80;
17491 196 break;
17492
17493 case down: //ur
17494 215 flip=0;
17495 215 tile+=88;
17496 215 break;
17497
17498 case r_up: //dl
17499 164 flip=0;
17500 164 tile+=120;
17501 164 break;
17502
17503 case right: //dr
17504 288 flip=0;
17505 288 tile+=128;
17506 288 break;
17507 }
17508
17509 2518 tile+=(f2*2);
17510 2518 xofs-=8;
17511 2518 yofs-=8;
17512 2518 drawblock(dest,15);
17513 2518 xofs+=8;
17514 2518 yofs+=8;
17515 }
17516 21250 }
17517 else
17518 {
17519
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 7057 times.
7572 if(!dmisc2)
17520 {
17521 7057 enemy::draw(dest);
17522 7057 }
17523 else
17524 {
17525 515 xofs-=8;
17526 515 yofs-=8;
17527 515 enemy::draw(dest);
17528 515 xofs+=16;
17529 515 enemy::draw(dest);
17530 515 yofs+=16;
17531 515 enemy::draw(dest);
17532 515 xofs-=16;
17533 515 enemy::draw(dest);
17534 515 xofs+=8;
17535 515 yofs-=8;
17536 }
17537 }
17538 28822 }
17539
17540 496 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
17541 496 {
17542 248 id=misc=clk;
17543 248 dir = clk & 3;
17544 248 clk=0;
17545 248 mainguy=count_enemy=false;
17546 248 dummy_bool[0]=false;
17547 248 item_set=0;
17548 248 bgsfx=-1;
17549 248 deadsfx = WAV_EDEAD;
17550 248 flags &= (~guy_neverret);
17551 248 isCore = false;
17552 //Probably will be buggy. -Z 12 AUG 2020
17553 248 SIZEflags = d->SIZEflags;
17554
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
248 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17555 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17556 // al_trace("Enemy txsz:%i\n", txsz);
17557
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
248 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
248 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
17559
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
248 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
17560
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
248 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17561
1/2
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
248 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17562
1/2
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
248 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17563 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17564
1/4
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
248 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
17565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17566 {
17567 yofs = d->yofs+(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17568 }
17569
17570
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
248 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
17571 248 }
17572
17573 91654 bool esManhandla::animate(int32_t index)
17574 {
17575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91654 times.
91654 if(switch_hooked) return enemy::animate(index);
17576
2/2
✓ Branch 0 taken 3384 times.
✓ Branch 1 taken 88270 times.
91654 if(dying)
17577 3384 return Dead(index);
17578
17579
2/2
✓ Branch 0 taken 5629 times.
✓ Branch 1 taken 82641 times.
88270 if(clk==0)
17580 {
17581 5629 removearmos(x,y,ffcactivated);
17582 5629 }
17583
17584
2/2
✓ Branch 0 taken 75539 times.
✓ Branch 1 taken 12731 times.
88270 if(--clk2<=0)
17585 {
17586 12731 clk2=unsigned(zc_oldrand())%5+5;
17587 12731 clk3^=1;
17588 12731 }
17589
17590
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 87572 times.
88270 if(!(zc_oldrand()&127))
17591 {
17592 698 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
17593 698 sfx(wpnsfx(wpn),pan(int32_t(x)));
17594 698 }
17595
17596 88270 return enemy::animate(index);
17597 91654 }
17598
17599 91646 void esManhandla::draw(BITMAP *dest)
17600 {
17601 91646 tile=o_tile;
17602 91646 int32_t fdiv = frate/4;
17603
1/2
✓ Branch 0 taken 91646 times.
✗ Branch 1 not taken.
91646 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17604
2/2
✓ Branch 0 taken 70295 times.
✓ Branch 1 taken 21351 times.
91646 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17605 91646 efrate:((clk>=(frate>>1))?1:0);
17606
17607
2/2
✓ Branch 0 taken 70295 times.
✓ Branch 1 taken 21351 times.
91646 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17608 {
17609
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 16874 times.
✓ Branch 2 taken 18626 times.
✓ Branch 3 taken 17275 times.
✓ Branch 4 taken 17520 times.
70295 switch(misc&3)
17610 {
17611 case up:
17612 16874 break;
17613
17614 case down:
17615 18626 tile+=4;
17616 18626 break;
17617
17618 case left:
17619 17275 tile+=8;
17620 17275 break;
17621
17622 case right:
17623 17520 tile+=12;
17624 17520 break;
17625 }
17626
17627 70295 tile+=f2;
17628 70295 }
17629 else
17630 {
17631
4/5
✓ Branch 0 taken 5269 times.
✓ Branch 1 taken 5957 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5807 times.
✓ Branch 4 taken 4318 times.
21351 switch(misc&3)
17632 {
17633 case down:
17634 5269 flip=2;
17635
17636 [[fallthrough]];
17637 case up:
17638 11076 tile=(clk3)?188:189;
17639 11076 break;
17640
17641 case right:
17642 5957 flip=1;
17643 [[fallthrough]];
17644
17645 case left:
17646 10275 tile=(clk3)?186:187;
17647 10275 break;
17648 }
17649 }
17650
17651 91646 enemy::draw(dest);
17652 91646 }
17653
17654 158 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
17655 158 {
17656
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if ( !(editorflags & ENEMY_FLAG5) )
17657 {
17658
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 x = 120;
17659
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 y = 48;
17660 79 }
17661 else
17662 {
17663 if ( !(editorflags & ENEMY_FLAG6) )
17664 {
17665 x = X; y = Y;
17666 }
17667 else
17668 {
17669 x = X+8; y = Y;
17670 }
17671 }
17672 79 hzsz = 32; // can't be jumped.
17673 79 flameclk=0;
17674 79 misc=clk; // total head count
17675 79 clk3=clk; // live head count
17676 79 clk=0;
17677 79 clk2=60; // fire ball clock
17678 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
17679
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 hp=(guysbuf[id&0xFFF].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
17680 79 dir = down;
17681 79 hxofs=4;
17682 79 hxsz=8;
17683 // frate=17*4;
17684 79 fading=fade_blue_poof;
17685 //nets+5420;
17686
3/4
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 14 times.
79 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17687 {
17688 /*
17689 necktile=o_tile+8;
17690 if (dmisc3)
17691 {
17692 necktile+=8;
17693 }
17694 */
17695 65 necktile=o_tile+dmisc6;
17696 65 }
17697 else
17698 {
17699 14 necktile=s_tile;
17700 }
17701 79 }
17702
17703 60815 bool eGleeok::animate(int32_t index)
17704 {
17705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60815 times.
60815 if(switch_hooked) return enemy::animate(index);
17706
2/2
✓ Branch 0 taken 1062 times.
✓ Branch 1 taken 59753 times.
60815 if(dying)
17707 1062 return Dead(index);
17708
17709
2/2
✓ Branch 0 taken 59480 times.
✓ Branch 1 taken 273 times.
59753 if(clk==0)
17710 {
17711 273 removearmos(x,y,ffcactivated);
17712 273 }
17713
17714 // Check if a head was killed somehow...
17715
2/2
✓ Branch 0 taken 31194 times.
✓ Branch 1 taken 28559 times.
59753 if(index+1+clk3>=guys.Count())
17716 28559 clk3=guys.Count()-index-1;
17717
2/2
✓ Branch 0 taken 13105 times.
✓ Branch 1 taken 46648 times.
59753 if(index+1+misc>=guys.Count())
17718 46648 misc=guys.Count()-index-1;
17719
17720 //fix for the "kill all enemies" item
17721
2/2
✓ Branch 0 taken 59747 times.
✓ Branch 1 taken 6 times.
59753 if(hp==-1000)
17722 {
17723
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
17724 {
17725 // I haven't seen this fail, but it seems like it ought to be
17726 // possible, so I'm checking for it. - Saf
17727
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
17728 break;
17729 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
17730 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
17731 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
17732 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
17733 12 }
17734
17735 6 clk3=0;
17736
17737
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
17738 {
17739
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
17740 break;
17741 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
17742 12 }
17743 6 }
17744
17745
2/2
✓ Branch 0 taken 136077 times.
✓ Branch 1 taken 59753 times.
195830 for(int32_t i=0; i<clk3; i++)
17746 {
17747 136077 enemy *head = ((enemy*)guys.spr(index+i+1));
17748 136077 head->dummy_int[1]=necktile;
17749 136077 head->parent_script_UID = this->script_UID;
17750
17751
2/2
✓ Branch 0 taken 98803 times.
✓ Branch 1 taken 37274 times.
136077 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17752 {
17753 98803 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
17754 98803 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
17755 98803 }
17756 else
17757 {
17758 37274 head->dummy_int[2]=necktile+1; //connected head tile
17759 37274 head->dummy_int[3]=necktile+2; //flying head tile
17760 }
17761
17762 136077 head->dmisc5=dmisc5; //neck segments
17763
17764 /*
17765 if (dmisc3)
17766 {
17767 head->dummy_bool[0]=true;
17768 }
17769 */
17770
2/2
✓ Branch 0 taken 133797 times.
✓ Branch 1 taken 2280 times.
136077 if(head->hclk)
17771 {
17772
2/2
✓ Branch 0 taken 1802 times.
✓ Branch 1 taken 478 times.
2280 if(hclk==0)
17773 {
17774 478 hp -= 1000 - head->hp;
17775 478 hclk = 33;
17776
17777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 478 times.
478 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
17778
17779 478 sfx(WAV_EHIT,pan(int32_t(head->x)));
17780 478 }
17781
17782 2280 head->hclk = 0;
17783 2280 }
17784
17785 // Must be set in case of naughty ZScripts
17786 136077 head->hp = 1000;
17787 136077 }
17788
17789
2/2
✓ Branch 0 taken 59594 times.
✓ Branch 1 taken 159 times.
59753 if(hp<=(guysbuf[id&0xFFF].misc2)*(clk3-1)*game->get_hero_dmgmult())
17790 {
17791 159 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
17792 159 hp=(guysbuf[id&0xFFF].misc2)*(--clk3)*game->get_hero_dmgmult();
17793 159 }
17794
17795
2/2
✓ Branch 0 taken 18578 times.
✓ Branch 1 taken 41175 times.
59753 if(!dmisc3)
17796 {
17797
4/4
✓ Branch 0 taken 2278 times.
✓ Branch 1 taken 38897 times.
✓ Branch 2 taken 557 times.
✓ Branch 3 taken 1721 times.
41175 if(++clk2>72 && !(zc_oldrand()&3))
17798 {
17799 557 int32_t i=zc_oldrand()%misc;
17800 557 enemy *head = ((enemy*)guys.spr(index+i+1));
17801 557 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
17802 557 sfx(wpnsfx(wpn),pan(int32_t(x)));
17803 557 clk2=0;
17804 557 }
17805 41175 }
17806 else
17807 {
17808
4/4
✓ Branch 0 taken 779 times.
✓ Branch 1 taken 17799 times.
✓ Branch 2 taken 598 times.
✓ Branch 3 taken 181 times.
18578 if(++clk2>100 && !(zc_oldrand()&3))
17809 {
17810 181 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
17811 181 head->timer=zc_oldrand()%50+50;
17812 181 clk2=0;
17813 181 }
17814 }
17815
17816
3/4
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 59694 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 59 times.
59753 if((hp<=0 && !immortal))
17817 {
17818
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 59 times.
212 for(int32_t i=0; i<misc; i++)
17819 153 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
17820
17821
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 56 times.
59 if(flags&guy_neverret) never_return(index);
17822 59 }
17823
17824 59753 return enemy::animate(index);
17825 60815 }
17826
17827 141 int32_t eGleeok::takehit(weapon*)
17828 {
17829 141 return 0;
17830 }
17831
17832 61133 void eGleeok::draw(BITMAP *dest)
17833 {
17834 61133 tile=o_tile;
17835
17836
2/2
✓ Branch 0 taken 1062 times.
✓ Branch 1 taken 60071 times.
61133 if(dying)
17837 {
17838 1062 enemy::draw(dest);
17839 1062 return;
17840 }
17841
17842 60071 int32_t f=clk/17;
17843
17844
2/2
✓ Branch 0 taken 43721 times.
✓ Branch 1 taken 16350 times.
60071 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17845 {
17846 // body
17847 43721 xofs=-8;
17848 43721 yofs=32;
17849
17850
4/4
✓ Branch 0 taken 33457 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 3364 times.
✓ Branch 3 taken 3289 times.
43721 switch(f)
17851
17852 {
17853 case 0:
17854 3611 tile+=0;
17855 3611 break;
17856
17857 case 1:
17858 3364 tile+=2;
17859 3364 break;
17860
17861 case 2:
17862 3289 tile+=4;
17863 3289 break;
17864
17865 default:
17866 33457 tile+=6;
17867 33457 break;
17868 }
17869 43721 }
17870 else
17871 {
17872 // body
17873 16350 xofs=-8;
17874 16350 yofs=32;
17875
17876
3/3
✓ Branch 0 taken 14042 times.
✓ Branch 1 taken 1169 times.
✓ Branch 2 taken 1139 times.
16350 switch(f)
17877 {
17878 case 0:
17879 1169 tile+=0;
17880 1169 break;
17881
17882 case 2:
17883 1139 tile+=4;
17884 1139 break;
17885
17886 default:
17887 14042 tile+=2;
17888 14042 break;
17889 }
17890 }
17891
17892 60071 enemy::drawblock(dest,15);
17893 61133 }
17894
17895 61133 void eGleeok::draw2(BITMAP *dest)
17896 {
17897 // the neck stub
17898 61133 tile=necktile;
17899 61133 xofs=0;
17900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61133 times.
61133 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17901
17902
2/2
✓ Branch 0 taken 16602 times.
✓ Branch 1 taken 44531 times.
61133 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17903 {
17904 44531 tile+=((clk&24)>>3);
17905 44531 }
17906
17907
3/4
✓ Branch 0 taken 60071 times.
✓ Branch 1 taken 1062 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 60071 times.
61133 if(hp > 0 && !dont_draw())
17908 {
17909
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 60071 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60071 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
17910 sprite::drawcloaked(dest);
17911 else
17912 60071 sprite::draw(dest);
17913 60071 }
17914 61133 }
17915
17916
4/8
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 230 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 230 times.
✗ Branch 7 not taken.
690 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
17917 460 {
17918
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 xoffset=0;
17919
2/4
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 230 times.
✗ Branch 3 not taken.
230 yoffset=(zfix)((dmisc5*4+2));
17920 // dummy_bool[0]=false;
17921 230 timer=0;
17922 /* fixing */
17923 230 hp=1000;
17924
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 step=1;
17925 230 item_set=0;
17926 //x=120; y=70;
17927
4/8
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 230 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 230 times.
✗ Branch 7 not taken.
230 x = xoffset+parent->x;
17928
4/8
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 230 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 230 times.
✗ Branch 7 not taken.
230 y = yoffset+parent->y;
17929 230 hxofs=4;
17930 230 hxsz=8;
17931
3/6
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 230 times.
✓ Branch 4 taken 230 times.
✗ Branch 5 not taken.
230 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17932 230 clk2=clk; // how int32_t to wait before moving first time
17933 230 clk=0;
17934 230 mainguy=count_enemy=false;
17935
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 dir=zc_oldrand();
17936 230 clk3=((dir&2)>>1)+2; // left or right
17937 230 dir&=1; // up or down
17938
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 dmisc5=vbound(dmisc5,1,255);
17939 230 isCore = false;
17940
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 parentCore = parent->getUID();
17941
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 230 times.
1150 for(int32_t i=0; i<dmisc5; i++)
17942 {
17943 920 nxoffset[i] = 0;
17944 920 nyoffset[i] = 0;
17945
2/4
✓ Branch 0 taken 920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 920 times.
✗ Branch 3 not taken.
920 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
17946
2/4
✓ Branch 0 taken 920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 920 times.
✗ Branch 3 not taken.
920 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
17947 920 }
17948
17949 230 necktile=0;
17950 //TODO compatibility? -DD
17951 /*
17952 for(int32_t i=0; i<4; i++)
17953 {
17954 nx[i]=124;
17955 ny[i]=i*6+48;
17956 }*/
17957 230 bgsfx=-1;
17958 //no need for deadsfx
17959 230 }
17960
17961 175322 bool esGleeok::animate(int32_t index)
17962 {
17963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175322 times.
175322 if(switch_hooked) return enemy::animate(index);
17964 // don't call removearmos() - it's a segment.
17965
17966 175322 dmisc5=vbound(dmisc5,1,255);
17967
17968
2/2
✓ Branch 0 taken 39398 times.
✓ Branch 1 taken 135924 times.
175322 if(misc == 0)
17969 {
17970 135924 x = (xoffset+parent->x);
17971 135924 y = (yoffset+parent->y);
17972
17973
2/2
✓ Branch 0 taken 543696 times.
✓ Branch 1 taken 135924 times.
679620 for(int32_t i=0; i<dmisc5; i++)
17974 {
17975 543696 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
17976 543696 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
17977 543696 }
17978 135924 }
17979
17980 // set up the head tiles
17981 // headtile=nets+5588; //5580, actually. must adjust for direction later on
17982 /*
17983 if (dummy_bool[0]) //if this is a flame gleeok
17984 {
17985 headtile+=180;
17986 }
17987 */
17988 175322 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
17989 175322 flyingheadtile=dummy_int[3];
17990
17991 // set up the neck tiles
17992 175322 necktile=dummy_int[1];
17993
17994
2/2
✓ Branch 0 taken 122856 times.
✓ Branch 1 taken 52466 times.
175322 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17995 {
17996 122856 necktile+=((clk&24)>>3);
17997 122856 }
17998
17999 /*
18000 else
18001 {
18002 necktile=145;
18003 }
18004 */
18005 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
18006
18007
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 135924 times.
✓ Branch 2 taken 39121 times.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 165 times.
175322 switch(misc)
18008 {
18009 case 0: // live head
18010 // set up the attached head tiles
18011 135924 tile=headtile;
18012
18013
2/2
✓ Branch 0 taken 98694 times.
✓ Branch 1 taken 37230 times.
135924 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18014 {
18015 98694 tile+=((clk&24)>>3);
18016 /*
18017 if (dummy_bool[0]) {
18018 tile+=1561;
18019 }
18020 */
18021 98694 }
18022
18023 /*
18024 else
18025 {
18026 tile=146;
18027 }
18028 */
18029
4/4
✓ Branch 0 taken 34657 times.
✓ Branch 1 taken 101267 times.
✓ Branch 2 taken 3844 times.
✓ Branch 3 taken 30813 times.
135924 if(++clk2>=0 && !(clk2&3))
18030 {
18031
2/2
✓ Branch 0 taken 30143 times.
✓ Branch 1 taken 670 times.
30813 if(y<= (int32_t)parent->y + 8) dir=down;
18032
18033
2/2
✓ Branch 0 taken 30175 times.
✓ Branch 1 taken 638 times.
30813 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
18034
18035
4/4
✓ Branch 0 taken 3217 times.
✓ Branch 1 taken 27596 times.
✓ Branch 2 taken 3131 times.
✓ Branch 3 taken 86 times.
30813 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
18036 {
18037 86 dir^=1;
18038 86 }
18039
18040 30813 zfix tempx = x;
18041 30813 zfix tempy = y;
18042
18043 30813 sprite::move(step);
18044 30813 xoffset += (x-tempx);
18045 30813 yoffset += (y-tempy);
18046
18047
2/2
✓ Branch 0 taken 1277 times.
✓ Branch 1 taken 29536 times.
30813 if(clk2>=4)
18048 {
18049 1277 clk3^=1;
18050 1277 clk2=-4;
18051 1277 }
18052 else
18053 {
18054
2/2
✓ Branch 0 taken 29232 times.
✓ Branch 1 taken 304 times.
29536 if(x <= (int32_t)parent->x-(dmisc5*6))
18055 {
18056 304 clk3=right;
18057 304 }
18058
18059
2/2
✓ Branch 0 taken 29207 times.
✓ Branch 1 taken 329 times.
29536 if(x >= (int32_t)parent->x+(dmisc5*6))
18060 {
18061 329 clk3=left;
18062 329 }
18063
18064
4/4
✓ Branch 0 taken 19921 times.
✓ Branch 1 taken 9615 times.
✓ Branch 2 taken 18716 times.
✓ Branch 3 taken 1205 times.
29536 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
18065 {
18066 1205 clk3^=1; // x jig
18067 1205 }
18068 else
18069 {
18070
4/4
✓ Branch 0 taken 9779 times.
✓ Branch 1 taken 18552 times.
✓ Branch 2 taken 9482 times.
✓ Branch 3 taken 297 times.
28331 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
18071 {
18072 297 clk3^=1; // x switch back
18073 297 }
18074
18075 28331 clk2=-4;
18076 }
18077 }
18078
18079 30813 zc_swap(dir,clk3);
18080 30813 tempx = x;
18081 30813 tempy = y;
18082 30813 sprite::move(step);
18083 30813 xoffset += (x-tempx);
18084 30813 yoffset += (y-tempy);
18085 30813 zc_swap(dir,clk3);
18086
18087
2/2
✓ Branch 0 taken 92439 times.
✓ Branch 1 taken 30813 times.
123252 for(int32_t i=1; i<dmisc5; i++)
18088 {
18089 92439 nxoffset[i] = (zc_oldrand()%3);
18090 92439 nyoffset[i] = (zc_oldrand()%3);
18091 92439 }
18092 30813 }
18093
18094 135924 break;
18095
18096 case 1: // flying head
18097
2/2
✓ Branch 0 taken 2300 times.
✓ Branch 1 taken 36821 times.
39121 if(clk>=0)
18098
18099 {
18100 36821 variable_walk_8(rate,homing,hrate,spw_floater);
18101 36821 }
18102
18103 39121 break;
18104
18105 // the following are messages sent from the main guy...
18106 case -1: // got chopped off
18107 {
18108 112 misc=1;
18109 112 superman=1;
18110 112 hxofs=xofs=0;
18111 112 hxsz=16;
18112 112 cs=8;
18113 112 clk=-24;
18114 112 clk2=40;
18115 112 dir=(zc_oldrand()&7)+8;
18116 112 step=8.0/9.0;
18117 }
18118 112 break;
18119
18120 case -2: // the big guy is dead
18121 165 return true;
18122 }
18123
18124
2/2
✓ Branch 0 taken 162831 times.
✓ Branch 1 taken 12326 times.
175157 if(timer)
18125 {
18126
2/2
✓ Branch 0 taken 10857 times.
✓ Branch 1 taken 1469 times.
12326 if(!(timer%8))
18127 {
18128 1469 FireBreath(true);
18129 1469 }
18130
18131 12326 --timer;
18132 12326 }
18133
18134 175157 return enemy::animate(index);
18135 175322 }
18136
18137 2909 int32_t esGleeok::takehit(weapon *w)
18138 {
18139
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2909 if ((editorflags & ENEMY_FLAG7) && misc == 1)
18140 {
18141 int32_t wpnId = w->id;
18142
18143 if(dying)
18144 return 0;
18145
18146 switch(wpnId)
18147 {
18148 case wLitBomb:
18149 case wLitSBomb:
18150 case wBait:
18151 case wWhistle:
18152 case wFire:
18153 case wWind:
18154 case wSSparkle:
18155 case wFSparkle:
18156 case wPhantom:
18157 return 0;
18158
18159 case wHookshot:
18160 case wBrang:
18161 case wBeam:
18162 case wArrow:
18163 case wMagic:
18164 case wBomb:
18165 case wSBomb:
18166 sfx(WAV_CHINK,pan(int32_t(x)));
18167 break;
18168 default:
18169 break;
18170 }
18171
18172 return 1;
18173 }
18174 else
18175 {
18176 2909 int32_t ret = enemy::takehit(w);
18177
18178
2/2
✓ Branch 0 taken 629 times.
✓ Branch 1 taken 2280 times.
2909 if(ret==-1)
18179 2280 return 2; // force it to wait a frame before checking sword attacks again
18180
18181 629 return ret;
18182 }
18183 2909 }
18184
18185 176009 void esGleeok::draw(BITMAP *dest)
18186 {
18187 176009 dmisc5=vbound(dmisc5,1,255);
18188
18189
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 136788 times.
✓ Branch 2 taken 39221 times.
176009 switch(misc)
18190 {
18191 case 0: //neck
18192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136788 times.
136788 if(!dont_draw())
18193 {
18194
2/2
✓ Branch 0 taken 410364 times.
✓ Branch 1 taken 136788 times.
547152 for(int32_t i=1; i<dmisc5; i++) //draw the neck
18195 {
18196
2/2
✓ Branch 0 taken 298542 times.
✓ Branch 1 taken 111822 times.
410364 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18197 {
18198
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 298542 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
298542 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
18199 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
18200 else
18201 298542 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
18202 298542 }
18203 else
18204 {
18205
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111822 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111822 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
18206 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
18207 else
18208 111822 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
18209 }
18210 410364 }
18211 136788 }
18212
18213 136788 break;
18214
18215 case 1: //flying head
18216 39221 tile=flyingheadtile;
18217
18218
2/2
✓ Branch 0 taken 15192 times.
✓ Branch 1 taken 24029 times.
39221 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18219 {
18220 24029 tile+=((clk&24)>>3);
18221 24029 break;
18222 }
18223
18224 /*
18225 else
18226 {
18227 tile=(clk&1)?147:148;
18228 break;
18229 }
18230 */
18231 15192 }
18232 176009 }
18233
18234 176009 void esGleeok::draw2(BITMAP *dest)
18235 {
18236 176009 enemy::draw(dest);
18237 176009 }
18238
18239 90 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
18240 90 {
18241
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if ( !(editorflags & ENEMY_FLAG5) )
18242 {
18243
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 x = 128;
18244
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 y = 48;
18245 45 }
18246 else { x = X; y = Y; }
18247 45 adjusted=false;
18248
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 dir=(zc_oldrand()&7)+8;
18249 //step=0.25;
18250 45 flycnt=dmisc1;
18251 45 flycnt2=dmisc2;
18252 45 loopcnt=0;
18253 45 clk4 = 0;
18254 45 clk5 = 0;
18255 45 clk6 = 0;
18256 45 clk7 = 0;
18257
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
18258 45 SIZEflags = d->SIZEflags;
18259
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
45 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
18260
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
18261 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
18262 // al_trace("Enemy txsz:%i\n", txsz);
18263
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
45 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
18264
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
18265
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
45 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
18266
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 else if (dmisc10 == 1) hxsz = 32;
18267
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
45 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
18268
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
45 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
18269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
18270
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 else if (dmisc10 == 1) hxofs = -8;
18271
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
18272 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
18273
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
45 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
18274
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
45 else if (dmisc10 == 1) xofs = -8;
18275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
18276 {
18277 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
18278 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
18279 }
18280
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
45 else if (dmisc10 == 1) yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)-8;
18281
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if (editorflags & ENEMY_FLAG8) misc = 1;
18282
18283
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
45 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
18284
18285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (dmisc29 == 0)
18286 {
18287
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 28 times.
45 if(!dmisc4)
18288 {
18289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if (dmisc10) dmisc29 = (90 / 3);
18290 28 else dmisc29 = (84 / 3);
18291 28 }
18292 else
18293 {
18294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if (dmisc10) dmisc29 = (90 / 2);
18295 17 else dmisc29 = (84 / 2);
18296 }
18297 45 }
18298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (dmisc30 == 0)
18299 {
18300
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 28 times.
45 if(!dmisc4)
18301 {
18302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if (dmisc10) dmisc30 = (90 / 3)*0.5;
18303 28 else dmisc30 = (84 / 3)*0.5;
18304 28 }
18305 else
18306 {
18307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if (dmisc10) dmisc30 = (90 / 2)*0.5;
18308 17 else dmisc30 = (84 / 2)*0.5;
18309 }
18310 45 }
18311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (dmisc31 == 0)
18312 {
18313
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 28 times.
45 if(!dmisc4)
18314 {
18315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if (dmisc10) dmisc31 = (90 / 3)*2;
18316 28 else dmisc31 = (84 / 3)*2;
18317 28 }
18318 else
18319 {
18320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if (dmisc10) dmisc31 = (90 / 2)*0.5;
18321 17 else dmisc31 = (84 / 2)*0.5;
18322 }
18323 45 }
18324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (dmisc32 == 0)
18325 {
18326
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 28 times.
45 if(!dmisc4)
18327 {
18328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if (dmisc10) dmisc32 = (90 / 3);
18329 28 else dmisc32 = (84 / 3);
18330 28 }
18331 else
18332 {
18333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if (dmisc10) dmisc32 = (90 / 2)*0.25;
18334 17 else dmisc32 = (84 / 2)*0.25;
18335 }
18336 45 }
18337 45 }
18338
18339 55559 bool ePatra::animate(int32_t index)
18340 {
18341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55559 times.
55559 if(switch_hooked) return enemy::animate(index);
18342
2/2
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 54857 times.
55559 if(dying)
18343 {
18344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 702 times.
702 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
18345 {
18346 ((enemy*)guys.spr(i))->hp = -1000;
18347 }
18348
18349 702 return Dead(index);
18350 }
18351
18352 54857 double basesize = 84;
18353
1/2
✓ Branch 0 taken 54857 times.
✗ Branch 1 not taken.
54857 if (dmisc10) basesize = 90;
18354 54857 double halfsize = basesize / 2;
18355 54857 double quartersize = halfsize / 2;
18356 54857 double twothirdsize = (basesize / 3)*2;
18357 54857 double onethirdsize = (basesize / 3);
18358
18359
18360
2/2
✓ Branch 0 taken 12020 times.
✓ Branch 1 taken 42837 times.
54857 if(clk==0)
18361 {
18362 12020 removearmos(x,y,ffcactivated);
18363 12020 }
18364
18365
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 54857 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54857 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54857 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
18366 {
18367
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 54857 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
54857 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
18368
1/2
✓ Branch 0 taken 54857 times.
✗ Branch 1 not taken.
54857 if (loopcnt < 0) ++clk2;
18369
2/2
✓ Branch 0 taken 54237 times.
✓ Branch 1 taken 620 times.
54857 if(++clk2>basesize)
18370 {
18371 620 clk2=0;
18372
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 620 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 620 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
620 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
18373 {
18374
2/2
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 298 times.
620 if(loopcnt > 0)
18375 322 --loopcnt;
18376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 298 times.
298 else if (loopcnt == 0)
18377 {
18378
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 114 times.
298 if((misc%dmisc6)==0)
18379 {
18380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (dmisc21 > 0) loopcnt=-dmisc21;
18381 114 else loopcnt=dmisc7;
18382 114 }
18383 298 }
18384 else if (loopcnt == -1) loopcnt=dmisc7;
18385 else ++loopcnt;
18386
18387
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 620 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
620 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
18388 620 }
18389 else
18390 {
18391 loopcnt = 0;
18392 misc = 1;
18393 }
18394 620 }
18395 54857 }
18396
1/2
✓ Branch 0 taken 54857 times.
✗ Branch 1 not taken.
54857 if (clk4 > 0) --clk4;
18397
18398 54857 double size=1;
18399
18400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54857 times.
54857 if (clk6 < 0)
18401 {
18402 if (dmisc5 == 1 || dmisc5 == 3)
18403 {
18404 if (get_bit(quest_rules,qr_NEWENEMYTILES))
18405 {
18406 if (clk7 <= 0 || clk6 != -16) ++clk6;
18407 if (clk6 == 0) o_tile=d->e_tile;
18408 else
18409 {
18410 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
18411 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
18412 }
18413 }
18414 else clk6 = 0;
18415 }
18416 }
18417
1/2
✓ Branch 0 taken 54857 times.
✗ Branch 1 not taken.
54857 else if (dmisc19) ++clk6;
18418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54857 times.
54857 if (clk5 < 0) ++clk5;
18419
1/2
✓ Branch 0 taken 54857 times.
✗ Branch 1 not taken.
54857 else if (dmisc19) ++clk5;
18420
18421
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54857 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54857 if (clk7 > 0 && clk6 >= -16) --clk7;
18422
1/2
✓ Branch 0 taken 54857 times.
✗ Branch 1 not taken.
54857 if (clk6 > 0) clk7 = 0;
18423
18424
2/2
✓ Branch 0 taken 211948 times.
✓ Branch 1 taken 54857 times.
266805 for(int32_t i=index+1; i<index+flycnt+1; i++)
18425 {
18426 //outside ring
18427
2/2
✓ Branch 0 taken 211588 times.
✓ Branch 1 taken 360 times.
211948 if(!adjusted)
18428 {
18429
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 88 times.
360 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18430 {
18431 272 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
18432 272 enemy *s = ((enemy*)guys.spr(i));
18433 272 s->parent_script_UID = this->script_UID;
18434 272 }
18435 else
18436 {
18437 88 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
18438 88 enemy *s = ((enemy*)guys.spr(i));
18439 88 s->parent_script_UID = this->script_UID;
18440 }
18441
18442 360 ((enemy*)guys.spr(i))->cs=dmisc9;
18443 360 ((enemy*)guys.spr(i))->hp=dmisc3;
18444 360 }
18445
18446
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 211636 times.
211948 if(((enemy*)guys.spr(i))->hp <= 0)
18447 {
18448
2/2
✓ Branch 0 taken 1189 times.
✓ Branch 1 taken 312 times.
1501 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
18449 {
18450 1189 guys.swap(j,j+1);
18451 1189 }
18452
18453
3/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 273 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
312 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
18454 312 }
18455 else
18456 {
18457 211636 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
18458
1/2
✓ Branch 0 taken 211636 times.
✗ Branch 1 not taken.
211636 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
18459
18460
2/2
✓ Branch 0 taken 77505 times.
✓ Branch 1 taken 134131 times.
211636 if(!dmisc4) //Big Ring
18461 {
18462 //maybe playing_field_offset here?
18463
2/2
✓ Branch 0 taken 61214 times.
✓ Branch 1 taken 72917 times.
134131 if(loopcnt>0)
18464 {
18465
1/2
✓ Branch 0 taken 72917 times.
✗ Branch 1 not taken.
72917 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
18466
1/2
✓ Branch 0 taken 72917 times.
✗ Branch 1 not taken.
72917 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
18467 72917 }
18468 else
18469 {
18470 61214 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18471 61214 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
18472 }
18473
18474 134131 temp_x=guys.spr(i)->x;
18475 134131 temp_y=guys.spr(i)->y;
18476 134131 }
18477 else //Oval
18478 {
18479 77505 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18480 77505 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
18481
18482
2/2
✓ Branch 0 taken 44593 times.
✓ Branch 1 taken 32912 times.
77505 if(loopcnt>0)
18483 {
18484 44593 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44593 times.
44593 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
18486 44593 }
18487 else
18488 {
18489 32912 guys.spr(i)->x = circle_x;
18490 32912 guys.spr(i)->y = circle_y;
18491 }
18492
18493 77505 temp_x=circle_x;
18494 77505 temp_y=circle_y;
18495 }
18496
18497 double _MSVC2022_tmp1, _MSVC2022_tmp2;
18498 211636 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
18499
18500
4/4
✓ Branch 0 taken 40124 times.
✓ Branch 1 taken 171512 times.
✓ Branch 2 taken 13266 times.
✓ Branch 3 taken 26858 times.
211636 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
18501 {
18502 26858 guys.spr(i)->dir=l_down;
18503 26858 }
18504
4/4
✓ Branch 0 taken 40238 times.
✓ Branch 1 taken 144540 times.
✓ Branch 2 taken 13266 times.
✓ Branch 3 taken 26972 times.
184778 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
18505 {
18506 26972 guys.spr(i)->dir=left;
18507 26972 }
18508
4/4
✓ Branch 0 taken 40004 times.
✓ Branch 1 taken 117802 times.
✓ Branch 2 taken 13266 times.
✓ Branch 3 taken 26738 times.
157806 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
18509 {
18510 26738 guys.spr(i)->dir=l_up;
18511 26738 }
18512
4/4
✓ Branch 0 taken 39715 times.
✓ Branch 1 taken 91353 times.
✓ Branch 2 taken 13266 times.
✓ Branch 3 taken 26449 times.
131068 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
18513 {
18514 26449 guys.spr(i)->dir=up;
18515 26449 }
18516
4/4
✓ Branch 0 taken 39428 times.
✓ Branch 1 taken 65191 times.
✓ Branch 2 taken 13266 times.
✓ Branch 3 taken 26162 times.
104619 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
18517 {
18518 26162 guys.spr(i)->dir=r_up;
18519 26162 }
18520
4/4
✓ Branch 0 taken 39237 times.
✓ Branch 1 taken 39220 times.
✓ Branch 2 taken 13266 times.
✓ Branch 3 taken 25971 times.
78457 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
18521 {
18522 25971 guys.spr(i)->dir=right;
18523 25971 }
18524
4/4
✓ Branch 0 taken 39264 times.
✓ Branch 1 taken 13222 times.
✓ Branch 2 taken 13266 times.
✓ Branch 3 taken 25998 times.
52486 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
18525 {
18526 25998 guys.spr(i)->dir=r_down;
18527 25998 }
18528 else
18529 {
18530 26488 guys.spr(i)->dir=down;
18531 }
18532
18533 211636 guys.spr(i)->x += x;
18534 211636 guys.spr(i)->y += y;
18535 }
18536 211948 }
18537
18538
7/22
✓ Branch 0 taken 33241 times.
✓ Branch 1 taken 21616 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33241 times.
✓ Branch 4 taken 5813 times.
✓ Branch 5 taken 15803 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5813 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 15803 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
54857 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
18539 {
18540 15803 int timeneeded = 48;
18541 15803 int patbreath = (zc_oldrand()%50+50);
18542
2/2
✓ Branch 0 taken 11961 times.
✓ Branch 1 taken 3842 times.
15803 if ((patbreath % 4) == 0) ++patbreath;
18543
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratBREATH)
18544 {
18545 timeneeded = 48 + patbreath;
18546 }
18547
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratSTREAM)
18548 {
18549 timeneeded = 48 + 96;
18550 }
18551
4/14
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15803 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 133 times.
✓ Branch 11 taken 133 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
15803 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
18552
2/2
✓ Branch 0 taken 15803 times.
✓ Branch 1 taken 133 times.
15936 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
18553
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15670 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15936 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18554 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)))))
18555 133 && (clk6 >= 0) //if not in the middle of firing...
18556 133 && clk6 >= dmisc19) //if over the set cooldown between shots...
18557
2/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
133 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
18558 {
18559
1/3
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
133 switch(dmisc28)
18560 {
18561 case patratSTREAM:
18562 {
18563 clk7 = 97;
18564 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) clk6 = -48;
18565 else clk6 = 0;
18566 break;
18567 }
18568 case patratBREATH:
18569 {
18570 clk7 = patbreath;
18571 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) clk6 = -48;
18572 else clk6 = 0;
18573 break;
18574 }
18575 default:
18576 {
18577
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18578 {
18579 clk6 = -48;
18580 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18581 }
18582 else
18583 {
18584 133 clk6 = 0;
18585
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18586 133 FirePatraWeapon();
18587 }
18588 133 break;
18589 }
18590 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18591 133 }
18592
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (clk6 < 0)
18593 {
18594 switch(dmisc28)
18595 {
18596 case patratSTREAM:
18597 {
18598 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
18599 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18600 break;
18601 }
18602 case patratBREATH:
18603 {
18604 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
18605 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18606 break;
18607 }
18608 default:
18609 {
18610 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && clk6 == -16)
18611 {
18612 FirePatraWeapon();
18613 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18614 }
18615 break;
18616 }
18617 }
18618 }
18619 15803 }
18620
18621 54857 size=.5;
18622 54857 int randattempts = 0;
18623 54857 int randeye = 0;
18624
2/2
✓ Branch 0 taken 38255 times.
✓ Branch 1 taken 16602 times.
54857 if (flycnt2 > 0)
18625 {
18626 16602 do
18627 {
18628
2/4
✓ Branch 0 taken 16602 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16602 times.
16602 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
18629 16602 randeye += (index + flycnt + 1);
18630 16602 ++randattempts;
18631
2/4
✓ Branch 0 taken 16602 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16602 times.
16602 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
18632 16602 }
18633 54857 bool dofire = false;
18634
1/2
✓ Branch 0 taken 54857 times.
✗ Branch 1 not taken.
54857 if (dmisc20)
18635 {
18636 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
18637 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
18638 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
18639 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) || dmisc20 == 2))
18640 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
18641 {
18642 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18643 {
18644 if (clk5 >= dmisc19)
18645 {
18646 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
18647 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
18648 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
18649 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
18650 || dmisc18 == -1)
18651 dofire = true;
18652 }
18653 }
18654 }
18655 }
18656
2/2
✓ Branch 0 taken 38255 times.
✓ Branch 1 taken 16602 times.
54857 if(flycnt2)
18657 {
18658
2/2
✓ Branch 0 taken 119975 times.
✓ Branch 1 taken 16602 times.
136577 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
18659 {
18660
2/2
✓ Branch 0 taken 119887 times.
✓ Branch 1 taken 88 times.
119975 if(!adjusted)
18661 {
18662 88 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
18663
18664
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18665 {
18666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if (get_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS))
18667 {
18668
2/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
88 switch(dmisc5)
18669 {
18670 // Center eye shoots projectiles; make room for its firing tiles
18671 case 1:
18672 case 3:
18673 48 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
18674 48 break;
18675
18676 // Center eyes does not shoot; use tiles two rows below for inner eyes.
18677 default:
18678 case 2:
18679 40 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
18680 40 break;
18681 }
18682 88 }
18683 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
18684 88 }
18685 else
18686 {
18687 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
18688 }
18689
18690 88 ((enemy*)guys.spr(i))->cs=dmisc9;
18691
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
18692 88 }
18693
18694
2/2
✓ Branch 0 taken 94136 times.
✓ Branch 1 taken 25839 times.
119975 if(flycnt>0)
18695 {
18696 94136 ((enemy*)guys.spr(i))->superman=true;
18697 94136 }
18698 else
18699 {
18700 25839 ((enemy*)guys.spr(i))->superman=false;
18701 }
18702
18703
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 119903 times.
119975 if(((enemy*)guys.spr(i))->hp <= 0)
18704 {
18705
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 72 times.
216 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
18706 {
18707 144 guys.swap(j,j+1);
18708 144 }
18709
18710
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
72 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
18711 72 }
18712 else
18713 {
18714 119903 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
18715
1/2
✓ Branch 0 taken 119903 times.
✗ Branch 1 not taken.
119903 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
18716
18717
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 112644 times.
119903 if(dmisc4==0)
18718 {
18719
2/2
✓ Branch 0 taken 58268 times.
✓ Branch 1 taken 54376 times.
112644 if(loopcnt>0)
18720 {
18721
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
18722
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
18723 58268 }
18724 else
18725 {
18726 54376 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18727 54376 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
18728 }
18729
18730 112644 temp_x=guys.spr(i)->x;
18731 112644 temp_y=guys.spr(i)->y;
18732 112644 }
18733 else
18734 {
18735 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18736 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
18737
18738
2/2
✓ Branch 0 taken 3294 times.
✓ Branch 1 taken 3965 times.
7259 if(loopcnt>0)
18739 {
18740 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18741
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
18742 3965 }
18743 else
18744 {
18745 3294 guys.spr(i)->x = circle_x;
18746 3294 guys.spr(i)->y = circle_y;
18747 }
18748
18749 7259 temp_x=circle_x;
18750 7259 temp_y=circle_y;
18751 }
18752
18753 double _MSVC2022_tmp1, _MSVC2022_tmp2;
18754 119903 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
18755
18756
4/4
✓ Branch 0 taken 22203 times.
✓ Branch 1 taken 97700 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14941 times.
119903 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
18757 {
18758 14941 guys.spr(i)->dir=l_down;
18759 14941 }
18760
4/4
✓ Branch 0 taken 22190 times.
✓ Branch 1 taken 82772 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14928 times.
104962 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
18761 {
18762 14928 guys.spr(i)->dir=left;
18763 14928 }
18764
4/4
✓ Branch 0 taken 22199 times.
✓ Branch 1 taken 67835 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14937 times.
90034 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
18765 {
18766 14937 guys.spr(i)->dir=l_up;
18767 14937 }
18768
4/4
✓ Branch 0 taken 22258 times.
✓ Branch 1 taken 52839 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14996 times.
75097 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
18769 {
18770 14996 guys.spr(i)->dir=up;
18771 14996 }
18772
4/4
✓ Branch 0 taken 22303 times.
✓ Branch 1 taken 37798 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15041 times.
60101 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
18773 {
18774 15041 guys.spr(i)->dir=r_up;
18775 15041 }
18776
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 22763 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
45060 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
18777 {
18778 15035 guys.spr(i)->dir=right;
18779 15035 }
18780
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 7728 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
30025 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
18781 {
18782 15035 guys.spr(i)->dir=r_down;
18783 15035 }
18784 else
18785 {
18786 14990 guys.spr(i)->dir=down;
18787 }
18788
18789 119903 guys.spr(i)->x += x;
18790 119903 guys.spr(i)->y = y-guys.spr(i)->y;
18791
18792
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 119903 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81826 times.
✓ Branch 5 taken 38077 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 81826 times.
119903 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
18793 {
18794 /*
18795 if(!(zc_oldrand()&127))
18796 {
18797 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
18798 sfx(wpnsfx(wpn),pan(int32_t(x)));
18799 }
18800 */
18801
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38077 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
18802 {
18803 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
18804 if (get_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS))
18805 {
18806 if (dmisc5 == 3)
18807 {
18808 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18809 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
18810 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
18811 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18812 }
18813 else
18814 {
18815 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
18816 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18817 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
18818 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
18819 }
18820 }
18821 else
18822 {
18823 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
18824 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
18825 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
18826 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
18827 }
18828 }
18829
4/6
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38077 times.
✓ Branch 4 taken 38077 times.
✓ Branch 5 taken 38077 times.
38077 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
18830
1/2
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
38077 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
18831
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
18832 {
18833
1/5
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
38077 switch(dmisc20) //Patra Attack Patterns
18834 {
18835 case 4: //Single one rapidfires
18836 {
18837 if (dofire && i == randeye)
18838 {
18839 ((esPatra*)guys.spr(i))->clk5 = -16;
18840 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
18841 ((esPatra*)guys.spr(i))->clk4 = 96;
18842 clk5 = -3;
18843 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
18844 }
18845 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
18846 {
18847 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18848 sfx(wpnsfx(wpn),pan(int32_t(x)));
18849 }
18850 break;
18851 }
18852 case 3: //Ring
18853 {
18854 if (dofire)
18855 {
18856 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18857 {
18858 ((esPatra*)guys.spr(i))->clk5 = -48;
18859 clk5 = -48;
18860 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18861 }
18862 else
18863 {
18864 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18865 sfx(wpnsfx(wpn),pan(int32_t(x)));
18866 int32_t m=Ewpns.Count()-1;
18867 weapon *ew = (weapon*)(Ewpns.spr(m));
18868
18869 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18870 ((esPatra*)guys.spr(i))->clk5 = 0;
18871 clk5 = 0;
18872 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18873 }
18874 }
18875 if (((esPatra*)guys.spr(i))->clk5 == -16)
18876 {
18877 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18878 sfx(wpnsfx(wpn),pan(int32_t(x)));
18879 int32_t m=Ewpns.Count()-1;
18880 weapon *ew = (weapon*)(Ewpns.spr(m));
18881
18882 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18883 }
18884 break;
18885 }
18886 case 2: //one after another
18887 {
18888 if (dofire)
18889 {
18890 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
18891 clk5 = -48 - (12*flycnt2);
18892 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
18893 }
18894 if (((esPatra*)guys.spr(i))->clk5 == -16)
18895 {
18896 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18897 sfx(wpnsfx(wpn),pan(int32_t(x)));
18898 }
18899 break;
18900 }
18901 case 1: //random one eye
18902 {
18903 if (dofire && i == randeye)
18904 {
18905 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18906 {
18907 ((esPatra*)guys.spr(i))->clk5 = -48;
18908 clk5 = -48;
18909 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18910 }
18911 else
18912 {
18913 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18914 sfx(wpnsfx(wpn),pan(int32_t(x)));
18915 ((esPatra*)guys.spr(i))->clk5 = 0;
18916 clk5 = 0;
18917 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18918 }
18919 }
18920 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
18921 {
18922 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18923 sfx(wpnsfx(wpn),pan(int32_t(x)));
18924 }
18925 break;
18926 }
18927 default: //old behavior, all eyes can fire any time
18928 {
18929
3/8
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 292 times.
✓ Branch 5 taken 292 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
18930
3/6
✓ Branch 0 taken 38077 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 292 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18931
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
18932 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
18933 {
18934
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18935 {
18936 ((esPatra*)guys.spr(i))->clk5 = -48;
18937 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18938 }
18939 else
18940 {
18941 292 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
18942 292 sfx(wpnsfx(wpn),pan(int32_t(x)));
18943 292 ((esPatra*)guys.spr(i))->clk5 = 0;
18944
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18945 }
18946 292 }
18947
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
18948 {
18949 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
18950 sfx(wpnsfx(wpn),pan(int32_t(x)));
18951 }
18952 38077 break;
18953 }
18954 }
18955 38077 }
18956 38077 }
18957
18958 }
18959 119975 }
18960 16602 }
18961
18962 54857 adjusted=true;
18963 54857 return enemy::animate(index);
18964 55559 }
18965
18966 133 void ePatra::FirePatraWeapon()
18967 { //.707
18968 133 int32_t xoff = 0;
18969 133 int32_t yoff = 0;
18970
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
18971 {
18972 xoff += (hxsz/2)-8;
18973 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
18974 }
18975
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
18976 {
18977 yoff += (hysz/2)-8;
18978 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
18979 }
18980 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
18981
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
133 switch (dmisc28)
18982 {
18983 case patrat8SHOT: //Fire Wizzrobe
18984 case patrat4SHOTDIAG:
18985 case patrat4SHOTRAND:
18986 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
18987 {
18988 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
18989 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18990 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18991 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
18992
18993 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
18994 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18996 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
18997
18998 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
18999 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19000 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19001 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
19002
19003 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
19004 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19005 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19006 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
19007
19008 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
19009 }
19010
19011 [[fallthrough]];
19012 case patrat4SHOTCARD: //Stalfos 3
19013 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
19014 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19015 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19016 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
19017 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19018 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19019 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
19020 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19021 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19022 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
19023 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19024 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19025 break;
19026
19027 default:
19028 133 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19029
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
19030 133 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
19031
3/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
133 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19032
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 133 times.
133 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
19033 {
19034 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19035 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
19036 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
19037 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19038 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19039 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
19040 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
19041 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19042 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
19043 {
19044 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19045 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
19046 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
19047 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19048 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19049 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
19050 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
19051 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19052 }
19053 }
19054 133 break;
19055
19056 }
19057 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
19058 //+0.46364761
19059 //11.80
19060 133 }
19061
19062 111282 void ePatra::draw(BITMAP *dest)
19063 {
19064 111282 tile=o_tile;
19065 111282 update_enemy_frame();
19066 111282 enemy::draw(dest);
19067 111282 }
19068
19069 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
19070 {
19071 int32_t ret = enemy::defend(wpnId, power, edef);
19072
19073 if(ret < 0 && (flycnt||flycnt2))
19074 return 0;
19075
19076 return ret;
19077 }
19078
19079 780 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
19080 {
19081 780 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
19082
19083
6/6
✓ Branch 0 taken 751 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 382 times.
✓ Branch 3 taken 369 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 130 times.
780 if(ret < 0 && (flycnt||flycnt2))
19084 621 return 0;
19085
19086 159 return ret;
19087 780 }
19088
19089 1344 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
19090 896 {
19091 //cs=8;
19092 448 item_set=0;
19093 448 misc=clk;
19094 448 clk4 = 0;
19095 448 clk5 = 0;
19096 448 clk = -((misc*21)>>1)-1;
19097
3/6
✓ Branch 0 taken 448 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 448 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 448 times.
✗ Branch 5 not taken.
448 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
19098 448 hxsz=12;
19099 448 hysz=12;
19100 448 hxofs=2;
19101 448 hyofs=2;
19102 448 extend = 0;
19103 448 txsz = 1;
19104 448 tysz = 1;
19105 /* //These need to be separate enemy editor fields. This enemy class also it's draw altered to correctly support big stuff.
19106 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
19107 int32_t prntSIZEflags = prntenemy->SIZEflags;
19108 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19109 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19110 // al_trace("Enemy txsz:%i\n", txsz);
19111 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
19112 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
19113 else
19114 hxsz=12;
19115 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
19116 else
19117 hysz=12;
19118 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
19119 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
19120 else
19121 hxofs=2;
19122 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
19123 else hyofs=2;
19124 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19125 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
19126 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19127 {
19128 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
19129 }
19130
19131 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
19132 */
19133 448 mainguy=count_enemy=false;
19134 448 bgsfx=-1;
19135 //o_tile=0;
19136 448 flags &= (~guy_neverret);
19137 448 deadsfx = WAV_EDEAD;
19138 448 hitsfx = WAV_EHIT;
19139 448 isCore = false;
19140 448 }
19141
19142 339094 bool esPatra::animate(int32_t index)
19143 {
19144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339094 times.
339094 if(switch_hooked) return enemy::animate(index);
19145
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 332182 times.
339094 if(dying)
19146 6912 return Dead(index);
19147
19148 332182 return enemy::animate(index);
19149 339094 }
19150
19151 680700 void esPatra::draw(BITMAP *dest)
19152 {
19153
2/2
✓ Branch 0 taken 544720 times.
✓ Branch 1 taken 135980 times.
680700 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19154 {
19155 544720 tile = o_tile+(clk&3);
19156
19157
8/9
✓ Branch 0 taken 67770 times.
✓ Branch 1 taken 69066 times.
✓ Branch 2 taken 67800 times.
✓ Branch 3 taken 67996 times.
✓ Branch 4 taken 67484 times.
✓ Branch 5 taken 68044 times.
✓ Branch 6 taken 68474 times.
✓ Branch 7 taken 68086 times.
✗ Branch 8 not taken.
544720 switch(dir) //directions get screwed up after 8. *shrug*
19158 {
19159 case up: //u
19160 67770 flip=0;
19161 67770 break;
19162
19163 case down: //d
19164 69066 flip=0;
19165 69066 tile+=4;
19166 69066 break;
19167
19168 case left: //l
19169 67800 flip=0;
19170 67800 tile+=8;
19171 67800 break;
19172
19173 case right: //r
19174 67996 flip=0;
19175 67996 tile+=12;
19176 67996 break;
19177
19178 case l_up: //ul
19179 67484 flip=0;
19180 67484 tile+=20;
19181 67484 break;
19182
19183 case r_up: //ur
19184 68044 flip=0;
19185 68044 tile+=24;
19186 68044 break;
19187
19188 case l_down: //dl
19189 68474 flip=0;
19190 68474 tile+=28;
19191 68474 break;
19192
19193 case r_down: //dr
19194 68086 flip=0;
19195 68086 tile+=32;
19196 68086 break;
19197 }
19198 544720 }
19199 else
19200 {
19201 135980 tile = o_tile+((clk&2)>>1);
19202 }
19203
19204
2/2
✓ Branch 0 taken 33568 times.
✓ Branch 1 taken 647132 times.
680700 if(clk>=0)
19205 647132 enemy::draw(dest);
19206 680700 }
19207
19208
19209 6 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
19210 6 {
19211 3 adjusted=false;
19212
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dir=(zc_oldrand()&7)+8;
19213
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 step=0.25;
19214 3 clk4 = 0;
19215 3 clk5 = 0;
19216 //flycnt=6; flycnt2=0;
19217 3 flycnt=dmisc1;
19218 3 flycnt2=0; // PatraBS doesn't have inner rings!
19219 3 loopcnt=0;
19220
19221 3 SIZEflags = d->SIZEflags;
19222
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19223 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19224 // al_trace("Enemy txsz:%i\n", txsz);
19225
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
19226
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
19227 3 else hxsz = 32;
19228
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
19229
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
19230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
19231 3 else hxofs=-8;
19232
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
19233 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19234
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
19235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19236 {
19237 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
19238 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
19239 }
19240
19241
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
19242
19243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
19244
19245 //nets+4480;
19246 3 }
19247
19248 1862 bool ePatraBS::animate(int32_t index)
19249 {
19250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1862 times.
1862 if(switch_hooked) return enemy::animate(index);
19251
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1808 times.
1862 if(dying)
19252 54 return Dead(index);
19253
19254
2/2
✓ Branch 0 taken 1366 times.
✓ Branch 1 taken 442 times.
1808 if(clk==0)
19255 {
19256 442 removearmos(x,y,ffcactivated);
19257 442 }
19258
19259 1808 variable_walk_8(rate,homing,hrate,spw_floater);
19260
19261
2/2
✓ Branch 0 taken 1789 times.
✓ Branch 1 taken 19 times.
1808 if(++clk2>90)
19262 {
19263 19 clk2=0;
19264
19265
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
19 if(loopcnt)
19266 12 --loopcnt;
19267 else
19268 {
19269
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if((misc%dmisc6)==0)
19270 4 loopcnt=dmisc7;
19271 }
19272
19273 19 ++misc;
19274 19 }
19275
19276 // double size=1;;
19277
2/2
✓ Branch 0 taken 4455 times.
✓ Branch 1 taken 1808 times.
6263 for(int32_t i=index+1; i<index+flycnt+1; i++)
19278 {
19279
2/2
✓ Branch 0 taken 4437 times.
✓ Branch 1 taken 18 times.
4455 if(!adjusted)
19280 {
19281 18 ((enemy*)guys.spr(i))->hp=dmisc3;
19282
19283
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19284 {
19285 18 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
19286 18 }
19287 else
19288 {
19289 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
19290 }
19291
19292 18 ((enemy*)guys.spr(i))->cs = dmisc9;
19293 18 }
19294
19295
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4437 times.
4455 if(((enemy*)guys.spr(i))->hp <= 0)
19296 {
19297
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 18 times.
44 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
19298 {
19299 26 guys.swap(j,j+1);
19300 26 }
19301
19302 18 --flycnt;
19303 18 }
19304 else
19305 {
19306 4437 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
19307
1/2
✓ Branch 0 taken 4437 times.
✗ Branch 1 not taken.
4437 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
19308 4437 temp_x = zc::math::Cos(a2+PI/2)*45;
19309 4437 temp_y = -zc::math::Sin(a2+PI/2)*45;
19310
19311
2/2
✓ Branch 0 taken 2305 times.
✓ Branch 1 taken 2132 times.
4437 if(loopcnt>0)
19312 {
19313 2305 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
19314
1/2
✓ Branch 0 taken 2305 times.
✗ Branch 1 not taken.
2305 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
19315 2305 }
19316 else
19317 {
19318 2132 guys.spr(i)->x = temp_x;
19319 2132 guys.spr(i)->y = temp_y;
19320 }
19321
19322 double _MSVC2022_tmp1, _MSVC2022_tmp2;
19323 4437 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
19324
19325
4/4
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 3576 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 551 times.
4437 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
19326 {
19327 551 guys.spr(i)->dir=l_down;
19328 551 }
19329
4/4
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 3042 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 534 times.
3886 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
19330 {
19331 534 guys.spr(i)->dir=left;
19332 534 }
19333
4/4
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 2520 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 522 times.
3352 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
19334 {
19335 522 guys.spr(i)->dir=l_up;
19336 522 }
19337
4/4
✓ Branch 0 taken 874 times.
✓ Branch 1 taken 1956 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 564 times.
2830 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
19338 {
19339 564 guys.spr(i)->dir=up;
19340 564 }
19341
4/4
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1411 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 545 times.
2266 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
19342 {
19343 545 guys.spr(i)->dir=r_up;
19344 545 }
19345
4/4
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 849 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 562 times.
1721 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
19346 {
19347 562 guys.spr(i)->dir=right;
19348 562 }
19349
4/4
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 554 times.
1159 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
19350 {
19351 554 guys.spr(i)->dir=r_down;
19352 554 }
19353 else
19354 {
19355 605 guys.spr(i)->dir=down;
19356 }
19357
19358 4437 guys.spr(i)->x += x;
19359 4437 guys.spr(i)->y += y;
19360 }
19361 4455 }
19362
19363 1808 adjusted=true;
19364 1808 return enemy::animate(index);
19365 1862 }
19366
19367 3724 void ePatraBS::draw(BITMAP *dest)
19368 {
19369 3724 tile=o_tile;
19370
19371
1/2
✓ Branch 0 taken 3724 times.
✗ Branch 1 not taken.
3724 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19372 {
19373 double _MSVC2022_tmp1, _MSVC2022_tmp2;
19374 3724 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
19375
19376
4/4
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 3320 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 102 times.
3724 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
19377 {
19378 102 lookat=l_down;
19379 102 }
19380
4/4
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 3010 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 310 times.
3622 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
19381 {
19382 310 lookat=down;
19383 310 }
19384
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 2058 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 952 times.
3312 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
19385 {
19386 952 lookat=r_down;
19387 952 }
19388
4/4
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 1686 times.
2360 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
19389 {
19390 1686 lookat=right;
19391 1686 }
19392
4/4
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 180 times.
674 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
19393 {
19394 180 lookat=r_up;
19395 180 }
19396
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
494 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
19397 {
19398 lookat=up;
19399 }
19400
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
494 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
19401 {
19402 lookat=l_up;
19403 }
19404 else
19405 {
19406 494 lookat=left;
19407 }
19408
19409
6/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 494 times.
✓ Branch 4 taken 1686 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 180 times.
✓ Branch 7 taken 102 times.
✓ Branch 8 taken 952 times.
3724 switch(lookat) //directions get screwed up after 8. *shrug*
19410 {
19411 case up: //u
19412 flip=0;
19413 break;
19414
19415 case down: //d
19416 310 flip=0;
19417 310 tile+=8;
19418 310 break;
19419
19420 case left: //l
19421 494 flip=0;
19422 494 tile+=40;
19423 494 break;
19424
19425 case right: //r
19426 1686 flip=0;
19427 1686 tile+=48;
19428 1686 break;
19429
19430 case l_up: //ul
19431 flip=0;
19432 tile+=80;
19433 break;
19434
19435 case r_up: //ur
19436 180 flip=0;
19437 180 tile+=88;
19438 180 break;
19439
19440 case l_down: //dl
19441 102 flip=0;
19442 102 tile+=120;
19443 102 break;
19444
19445 case r_down: //dr
19446 952 flip=0;
19447 952 tile+=128;
19448 952 break;
19449 }
19450
19451 3724 tile+=(2*(clk&3));
19452 3724 xofs-=8;
19453 3724 yofs-=8;
19454 3724 drawblock(dest,15);
19455 3724 xofs+=8;
19456 3724 yofs+=8;
19457 3724 }
19458 else
19459 {
19460 flip=(clk&1);
19461 xofs-=8;
19462 yofs-=8;
19463 enemy::draw(dest);
19464 xofs+=16;
19465 enemy::draw(dest);
19466 yofs+=16;
19467 enemy::draw(dest);
19468 xofs-=16;
19469 enemy::draw(dest);
19470 xofs+=8;
19471 yofs-=8;
19472 }
19473 3724 }
19474
19475 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
19476 {
19477 int32_t ret = enemy::defend(wpnId, power, edef);
19478
19479 if(ret < 0 && (flycnt||flycnt2))
19480 return 0;
19481
19482 return ret;
19483 }
19484
19485 25 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
19486 {
19487 25 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
19488
19489
4/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
25 if(ret < 0 && (flycnt||flycnt2))
19490 19 return 0;
19491
19492 6 return ret;
19493 25 }
19494
19495 54 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
19496 36 {
19497 //cs=csBOSS;
19498 18 item_set=0;
19499 18 misc=clk;
19500 18 clk = -((misc*21)>>1)-1;
19501 18 clk4 = 0;
19502 18 clk5 = 0;
19503
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
19504 18 int32_t prntSIZEflags = prntenemy->SIZEflags;
19505
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19506 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19507 // al_trace("Enemy txsz:%i\n", txsz);
19508
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
19509
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
19510 18 else hxsz=16;
19511
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
19512 18 else hysz=16;
19513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
19514
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
19515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
19516 18 else hyofs=2;
19517 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19518
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
19519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19520 {
19521 yofs = (int32_t)prntenemy->yofs;
19522 }
19523
3/6
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
18 else yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
19524
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
19525
19526 18 bgsfx=-1;
19527 18 mainguy=count_enemy=false;
19528 18 deadsfx = WAV_EDEAD;
19529 18 hitsfx = WAV_EHIT;
19530 18 flags &= ~guy_neverret;
19531 18 isCore = false;
19532 18 }
19533
19534 4790 bool esPatraBS::animate(int32_t index)
19535 {
19536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4790 times.
4790 if(switch_hooked) return enemy::animate(index);
19537
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 4466 times.
4790 if(dying)
19538 324 return Dead(index);
19539
19540 4466 return enemy::animate(index);
19541 4790 }
19542
19543 9580 void esPatraBS::draw(BITMAP *dest)
19544 {
19545 9580 tile=o_tile;
19546
19547
1/2
✓ Branch 0 taken 9580 times.
✗ Branch 1 not taken.
9580 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19548 {
19549
8/9
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 1326 times.
✓ Branch 2 taken 1076 times.
✓ Branch 3 taken 1254 times.
✓ Branch 4 taken 1080 times.
✓ Branch 5 taken 1238 times.
✓ Branch 6 taken 1146 times.
✓ Branch 7 taken 1180 times.
✗ Branch 8 not taken.
9580 switch(dir) //directions get screwed up after 8. *shrug*
19550 {
19551 case up: //u
19552 1280 flip=0;
19553 1280 break;
19554
19555 case down: //d
19556 1326 flip=0;
19557 1326 tile+=4;
19558 1326 break;
19559
19560 case left: //l
19561 1076 flip=0;
19562 1076 tile+=8;
19563 1076 break;
19564
19565 case right: //r
19566 1254 flip=0;
19567 1254 tile+=12;
19568 1254 break;
19569
19570 case l_up: //ul
19571 1080 flip=0;
19572 1080 tile+=20;
19573 1080 break;
19574
19575 case r_up: //ur
19576 1238 flip=0;
19577 1238 tile+=24;
19578 1238 break;
19579
19580 case l_down: //dl
19581 1146 flip=0;
19582 1146 tile+=28;
19583 1146 break;
19584
19585 case r_down: //dr
19586 1180 flip=0;
19587 1180 tile+=32;
19588 1180 break;
19589 }
19590
19591 9580 tile += ((clk&6)>>1);
19592 9580 }
19593 else
19594 {
19595 tile += (clk&4)?1:0;
19596 }
19597
19598
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 8608 times.
9580 if(clk>=0)
19599 8608 enemy::draw(dest);
19600 9580 }
19601
19602
19603 /**********************************/
19604 /********** Misc Code ***********/
19605 /**********************************/
19606
19607 148769 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
19608 {
19609
4/6
✓ Branch 0 taken 116927 times.
✓ Branch 1 taken 31842 times.
✓ Branch 2 taken 116927 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116927 times.
✗ Branch 5 not taken.
148769 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
19610
4/8
✓ Branch 0 taken 148769 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148769 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148769 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 148769 times.
✗ Branch 7 not taken.
148769 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
19611
1/2
✓ Branch 0 taken 148769 times.
✗ Branch 1 not taken.
148769 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19612 148769 }
19613
19614 29171 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon)
19615 {
19616 // Kludge
19617
4/8
✓ Branch 0 taken 29171 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29171 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29171 times.
✗ Branch 7 not taken.
29171 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
19618 29171 int32_t ret= ((enemy*)guys.spr(index))->takehit(w);
19619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29171 times.
29171 delete w;
19620 29171 return ret;
19621 }
19622
19623 3055 void enemy_scored(int32_t index)
19624 {
19625 3055 ((enemy*)guys.spr(index))->scored=true;
19626 3055 }
19627
19628 975 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy)
19629 {
19630
7/12
✓ Branch 0 taken 975 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 975 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 975 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 975 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115 times.
✓ Branch 9 taken 860 times.
✓ Branch 10 taken 975 times.
✗ Branch 11 not taken.
975 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_bit(quest_rules,qr_NOGUYPOOF)?0:clk,mainguy);
19631 975 guys.add(g);
19632 975 }
19633
19634 21784 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
19635 {
19636
5/10
✓ Branch 0 taken 21784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21784 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21784 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21784 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21784 times.
✗ Branch 9 not taken.
21784 item *i = new item(zfix(x), zfix(y - get_bit(quest_rules, qr_NOITEMOFFSET)), zfix(0), id, pickup, 0);
19637 21784 items.add(i);
19638 21784 }
19639
19640 60 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
19641 {
19642
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
60 item *i = new item((zfix)x,(zfix)y-(get_bit(quest_rules, qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
19643 60 items.add(i);
19644 60 }
19645
19646 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
19647 {
19648 item *i = new item((zfix)x,(zfix)y-(get_bit(quest_rules, qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
19649 items.add(i);
19650 }
19651
19652 54 void kill_em_all()
19653 {
19654
2/2
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 54 times.
304 for(int32_t i=0; i<guys.Count(); i++)
19655 {
19656 250 enemy *e = ((enemy*)guys.spr(i));
19657
19658
3/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 225 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
250 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
19659
19660 225 e->kickbucket();
19661 225 }
19662 54 }
19663
19664 bool can_kill_em_all()
19665 {
19666 for(int32_t i=0; i<guys.Count(); i++)
19667 {
19668 enemy *e = ((enemy*)guys.spr(i));
19669
19670 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
19671 if(e->superman) continue;
19672 return true;
19673 }
19674 return false;
19675 }
19676
19677 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
19678 // For Hero's hit detection. Don't count them if they are stunned or are guys.
19679 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19680 {
19681 for(int32_t i=0; i<guys.Count(); i++)
19682 {
19683 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
19684 {
19685 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_bit(quest_rules, qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
19686 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
19687 {
19688 return i;
19689 }
19690 }
19691 }
19692
19693 return -1;
19694 }
19695
19696 4757937 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19697 {
19698
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4757937 times.
✓ Branch 2 taken 14171298 times.
✓ Branch 3 taken 4746877 times.
18918175 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
19699 {
19700
2/2
✓ Branch 0 taken 11060 times.
✓ Branch 1 taken 14160238 times.
14171298 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
19701 {
19702 11060 return i;
19703 }
19704 14160238 }
19705
19706 4746877 return -1;
19707 4757937 }
19708
19709 // For Hero's hit detection. Count them if they are dying.
19710 21301 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19711 {
19712 21301 enemy *e = (enemy*)guys.spr(index);
19713
3/4
✓ Branch 0 taken 21301 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12034 times.
✓ Branch 3 taken 9267 times.
21301 if(!e || e->hp > 0)
19714 12034 return -1;
19715
19716 9267 bool d = e->dying;
19717 9267 int32_t hc = e->hclk;
19718 9267 e->dying = false;
19719 9267 e->hclk = 0;
19720 9267 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
19721 9267 e->dying = d;
19722 9267 e->hclk = hc;
19723
19724
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 9201 times.
9267 return hit ? index : -1;
19725 21301 }
19726
19727 5165833 bool hasMainGuy()
19728 {
19729
2/2
✓ Branch 0 taken 6636797 times.
✓ Branch 1 taken 1902894 times.
8539691 for(int32_t i=0; i<guys.Count(); i++)
19730 {
19731
2/2
✓ Branch 0 taken 3262939 times.
✓ Branch 1 taken 3373858 times.
6636797 if(((enemy*)guys.spr(i))->mainguy)
19732 {
19733 3262939 return true;
19734 }
19735 3373858 }
19736
19737 1902894 return false;
19738 5165833 }
19739
19740 47 void EatHero(int32_t index)
19741 {
19742 47 ((eStalfos*)guys.spr(index))->eathero();
19743 47 }
19744
19745 3 void GrabHero(int32_t index)
19746 {
19747 3 ((eWallM*)guys.spr(index))->grabhero();
19748 3 }
19749
19750 292 bool CarryHero()
19751 {
19752
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 for(int32_t i=0; i<guys.Count(); i++)
19753 {
19754
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 355 times.
891 if(((guy*)(guys.spr(i)))->family==eeWALLM)
19755 {
19756
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 63 times.
355 if(((eWallM*)guys.spr(i))->hashero)
19757 {
19758 292 Hero.x=guys.spr(i)->x;
19759 292 Hero.y=guys.spr(i)->y;
19760 292 return ((eWallM*)guys.spr(i))->misc > 0;
19761 }
19762 63 }
19763
19764 // Like Likes currently can't carry Hero.
19765 /*
19766 if(((guy*)(guys.spr(i)))->family==eeLIKE)
19767 {
19768 if(((eLikeLike*)guys.spr(i))->hashero)
19769 {
19770 Hero.x=guys.spr(i)->x;
19771 Hero.y=guys.spr(i)->y;
19772 return (true);
19773 }
19774 }*/
19775 599 }
19776
19777 return false;
19778 292 }
19779
19780 // Move item with guy
19781 void movefairy(zfix &x,zfix &y,int32_t misc)
19782 {
19783 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19784
19785 if(i!=-1)
19786 {
19787 x = guys.spr(i)->x;
19788 y = guys.spr(i)->y;
19789 }
19790 }
19791
19792 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
19793 void movefairy2(zfix x,zfix y,int32_t misc)
19794 {
19795 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19796
19797 if(i!=-1)
19798 {
19799 guys.spr(i)->x = x;
19800 guys.spr(i)->y = y;
19801 }
19802 }// Move item with guy
19803
19804 26588 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
19805 {
19806 26588 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19807
19808
1/2
✓ Branch 0 taken 26588 times.
✗ Branch 1 not taken.
26588 if(fairy)
19809 {
19810 26588 x = fairy->x;
19811 26588 y = fairy->y;
19812 26588 }
19813 26588 }
19814
19815 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
19816 void movefairynew2(zfix x,zfix y, item const &itemfairy)
19817 {
19818 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19819
19820 if(fairy)
19821 {
19822 fairy->x = x;
19823 fairy->y = y;
19824 }
19825 }
19826
19827 void killfairy(int32_t misc)
19828 {
19829 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19830 guys.del(i);
19831 }
19832
19833 int32_t getGuyIndex(const int32_t eid)
19834 {
19835 for(word i = 0; i < guys.Count(); i++)
19836 {
19837 if(guys.spr(i)->getUID() == eid)
19838 return i;
19839 }
19840
19841 return -1;
19842 }
19843
19844 void killfairynew(item const &itemfairy)
19845 {
19846 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19847 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
19848 }
19849
19850 //Should probably change this to return an 'enemy*', null on failure -Em
19851 9475 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
19852 {
19853 9475 return addenemy(x,y,0,id,clk);
19854 }
19855
19856 868 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
19857 {
19858 868 return addchild(x,y,0,id,clk, parent_scriptUID);
19859 }
19860
19861 893 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
19862 {
19863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if(id <= 0) return 0;
19864
19865 893 int32_t ret = 0;
19866 893 sprite *e=NULL;
19867 893 al_trace("Adding child\n");
19868
19869
5/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 857 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
893 switch(guysbuf[id&0xFFF].family)
19870 {
19871 //Fixme: possible enemy memory leak. (minor)
19872 case eeWALK:
19873
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
16 e = new eStalfos((zfix)x,(zfix)y,id,clk);
19874 16 break;
19875
19876 case eeLEV:
19877 e = new eLeever((zfix)x,(zfix)y,id,clk);
19878 break;
19879
19880 case eeTEK:
19881 e = new eTektite((zfix)x,(zfix)y,id,clk);
19882 break;
19883
19884 case eePEAHAT:
19885 e = new ePeahat((zfix)x,(zfix)y,id,clk);
19886 break;
19887
19888 case eeZORA:
19889 e = new eZora((zfix)x,(zfix)y,id,clk);
19890 break;
19891
19892 case eeGHINI:
19893 e = new eGhini((zfix)x,(zfix)y,id,clk);
19894 break;
19895
19896 case eeKEESE:
19897
3/6
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 857 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 857 times.
✗ Branch 5 not taken.
857 e = new eKeese((zfix)x,(zfix)y,id,clk);
19898 857 break;
19899
19900 case eeWIZZ:
19901
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
19902 15 break;
19903
19904 case eePROJECTILE:
19905 e = new eProjectile((zfix)x,(zfix)y,id,clk);
19906 break;
19907
19908 case eeWALLM:
19909 e = new eWallM((zfix)x,(zfix)y,id,clk);
19910 break;
19911
19912 case eeAQUA:
19913 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
19914 break;
19915
19916 case eeMOLD:
19917 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
19918 break;
19919
19920 case eeMANHAN:
19921
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
19922 1 break;
19923
19924 case eeGLEEOK:
19925 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
19926 break;
19927
19928 case eeGHOMA:
19929 e = new eGohma((zfix)x,(zfix)y,id,clk);
19930 break;
19931
19932 case eeLANM:
19933 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
19934 break;
19935
19936 case eeGANON:
19937 e = new eGanon((zfix)x,(zfix)y,id,clk);
19938 break;
19939
19940 case eeFAIRY:
19941 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
19942 break;
19943
19944 case eeFIRE:
19945 e = new eFire((zfix)x,(zfix)y,id,clk);
19946 break;
19947
19948 case eeOTHER:
19949 e = new eOther((zfix)x,(zfix)y,id,clk);
19950 break;
19951
19952
19953 case eeSCRIPT01:
19954 case eeSCRIPT02:
19955 case eeSCRIPT03:
19956 case eeSCRIPT04:
19957 case eeSCRIPT05:
19958 case eeSCRIPT06:
19959 case eeSCRIPT07:
19960 case eeSCRIPT08:
19961 case eeSCRIPT09:
19962 case eeSCRIPT10:
19963 case eeSCRIPT11:
19964 case eeSCRIPT12:
19965 case eeSCRIPT13:
19966 case eeSCRIPT14:
19967 case eeSCRIPT15:
19968 case eeSCRIPT16:
19969 case eeSCRIPT17:
19970 case eeSCRIPT18:
19971 case eeSCRIPT19:
19972 case eeSCRIPT20:
19973 {
19974 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
19975 {
19976 e = new eScript((zfix)x,(zfix)y,id,clk);
19977 break;
19978 }
19979 else return 0;
19980 }
19981
19982 case eeFFRIENDLY01:
19983 case eeFFRIENDLY02:
19984 case eeFFRIENDLY03:
19985 case eeFFRIENDLY04:
19986 case eeFFRIENDLY05:
19987 case eeFFRIENDLY06:
19988 case eeFFRIENDLY07:
19989 case eeFFRIENDLY08:
19990 case eeFFRIENDLY09:
19991 case eeFFRIENDLY10:
19992 {
19993 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
19994 {
19995 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
19996 }
19997 else return 0;
19998
19999 }
20000
20001 case eeSPINTILE:
20002 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
20003 break;
20004
20005 // and these enemies use the misc10/misc2 value
20006 case eeROCK:
20007 {
20008 switch(guysbuf[id&0xFFF].misc10)
20009 {
20010 case 1:
20011 e = new eBoulder((zfix)x,(zfix)y,id,clk);
20012 break;
20013
20014 case 0:
20015 default:
20016 e = new eRock((zfix)x,(zfix)y,id,clk);
20017 break;
20018 }
20019
20020 break;
20021 }
20022
20023 case eeTRAP:
20024 {
20025 switch(guysbuf[id&0xFFF].misc2)
20026 {
20027 case 1:
20028 e = new eTrap2((zfix)x,(zfix)y,id,clk);
20029 break;
20030
20031 case 0:
20032 default:
20033 e = new eTrap((zfix)x,(zfix)y,id,clk);
20034 break;
20035 }
20036
20037 break;
20038 }
20039
20040 case eeDONGO:
20041 {
20042 switch(guysbuf[id&0xFFF].misc10)
20043 {
20044 case 1:
20045 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
20046 break;
20047
20048 case 0:
20049 default:
20050 e = new eDodongo((zfix)x,(zfix)y,id,clk);
20051 break;
20052 }
20053
20054 break;
20055 }
20056
20057 case eeDIG:
20058 {
20059
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].misc10)
20060 {
20061 case 1:
20062 e = new eLilDig((zfix)x,(zfix)y,id,clk);
20063 break;
20064
20065 4 case 0:
20066 default:
20067
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
20068 4 break;
20069 }
20070
20071 4 break;
20072 }
20073
20074 case eePATRA:
20075 {
20076 switch(guysbuf[id&0xFFF].misc10)
20077 {
20078 case 1:
20079 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
20080 {
20081 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
20082 break;
20083 }
20084 [[fallthrough]];
20085 case 0:
20086 default:
20087 e = new ePatra((zfix)x,(zfix)y,id,clk);
20088 break;
20089 }
20090
20091 break;
20092 }
20093
20094 case eeGUY:
20095 {
20096 switch(guysbuf[id&0xFFF].misc10)
20097 {
20098 case 1:
20099 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20100 break;
20101
20102 case 0:
20103 default:
20104 e = new eNPC((zfix)x,(zfix)y,id,clk);
20105 break;
20106 }
20107
20108 break;
20109 }
20110
20111 case eeNONE:
20112 if(guysbuf[id&0xFFF].misc10 ==1)
20113 {
20114 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20115 break;
20116 break;
20117 }
20118 [[fallthrough]];
20119 default:
20120
20121 return 0;
20122 }
20123
20124 893 ret++; // Made one enemy.
20125
20126
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
893 if(z && canfall(id))
20127 {
20128 e->z = (zfix)z;
20129 }
20130
20131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 ((enemy*)e)->ceiling = (z && canfall(id));
20132 893 ((enemy*)e)->parent_script_UID = parent_scriptUID;
20133 //al_trace("Child Script UID: %d\n",((enemy*)e)->script_UID);
20134 //zprint2("Child Script UID: %d\n",((enemy*)e)->script_UID);
20135 //al_trace("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
20136 //zprint2("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
20137
20138
20139
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 if(!guys.add(e))
20140 {
20141 return 0;
20142 }
20143
20144 // add segments of segmented enemies
20145 893 int32_t c=0;
20146
20147
2/6
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
893 switch(guysbuf[id&0xFFF].family)
20148 {
20149 case eeMOLD:
20150 {
20151 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20152 id &= 0xFFF;
20153
20154 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
20155 {
20156 //christ this is messy -DD
20157 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
20158
20159 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
20160 {
20161 al_trace("Moldorm segment %d could not be created!\n",i+1);
20162
20163 for(int32_t j=0; j<i+1; j++)
20164 guys.del(guys.Count()-1);
20165
20166 return 0;
20167 }
20168
20169 if(i>0)
20170 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20171
20172 ret++;
20173 }
20174
20175 break;
20176 }
20177
20178 case eeLANM:
20179 {
20180 id &= 0xFFF;
20181 int32_t shft = guysbuf[id].misc2;
20182 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20183
20184 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
20185 {
20186 al_trace("Lanmola segment 1 could not be created!\n");
20187 guys.del(guys.Count()-1);
20188 return 0;
20189 }
20190
20191 ret++;
20192
20193 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
20194 {
20195 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
20196 {
20197 al_trace("Lanmola segment %d could not be created!\n",i+1);
20198
20199 for(int32_t j=0; j<i+1; j++)
20200 guys.del(guys.Count()-1);
20201
20202 return 0;
20203 }
20204
20205 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20206 ret++;
20207 }
20208 }
20209 break;
20210
20211 case eeMANHAN:
20212 1 id &= 0xFFF;
20213
20214
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
20215 {
20216
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
20217 {
20218 al_trace("Manhandla head %d could not be created!\n",i+1);
20219
20220 for(int32_t j=0; j<i+1; j++)
20221 {
20222 guys.del(guys.Count()-1);
20223 }
20224
20225 return 0;
20226 }
20227
20228 4 ret++;
20229 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
20230 4 }
20231
20232 1 break;
20233
20234 case eeGLEEOK:
20235 {
20236 id &= 0xFFF;
20237
20238 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
20239 {
20240 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
20241 {
20242 al_trace("Gleeok head %d could not be created!\n",i+1);
20243
20244 for(int32_t j=0; j<i+1; j++)
20245 {
20246 guys.del(guys.Count()-1);
20247 }
20248
20249 return false;
20250 }
20251
20252 c-=guysbuf[id].misc4;
20253 ret++;
20254 }
20255 }
20256 break;
20257
20258
20259 case eePATRA:
20260 {
20261 id &= 0xFFF;
20262 int32_t outeyes = 0;
20263
20264 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
20265 {
20266 if(!((guysbuf[id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
20267 {
20268 al_trace("Patra outer eye %d could not be created!\n",i+1);
20269
20270 for(int32_t j=0; j<i+1; j++)
20271 guys.del(guys.Count()-1);
20272
20273 return 0;
20274 }
20275 else
20276 outeyes++;
20277
20278 ret++;
20279 }
20280
20281 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
20282 {
20283 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
20284 {
20285 al_trace("Patra inner eye %d could not be created!\n",i+1);
20286
20287 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
20288 guys.del(guys.Count()-1);
20289
20290 return 0;
20291 }
20292
20293 ret++;
20294 }
20295
20296 break;
20297 }
20298 }
20299
20300 893 return ret;
20301 893 }
20302
20303 // Returns number of enemies/segments created
20304 33345 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
20305 {
20306 //zprint2("addenemy id is: %d\n", (id&0xFFF));
20307 33345 int32_t realid = id&0xFFF;
20308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33345 times.
33345 if( realid > MAXGUYS )
20309 {
20310 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "addenemy()");
20311 return 0;
20312 }
20313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33345 times.
33345 if(id <= 0) return 0;
20314
20315 33345 int32_t ret = 0;
20316 33345 sprite *e=NULL;
20317
20318
26/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16941 times.
✓ Branch 4 taken 1097 times.
✓ Branch 5 taken 2000 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 1371 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 3625 times.
✓ Branch 10 taken 1647 times.
✓ Branch 11 taken 2019 times.
✓ Branch 12 taken 377 times.
✓ Branch 13 taken 63 times.
✓ Branch 14 taken 78 times.
✓ Branch 15 taken 53 times.
✓ Branch 16 taken 79 times.
✓ Branch 17 taken 44 times.
✓ Branch 18 taken 90 times.
✓ Branch 19 taken 6 times.
✓ Branch 20 taken 303 times.
✓ Branch 21 taken 75 times.
✓ Branch 22 taken 1278 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 196 times.
✓ Branch 25 taken 665 times.
✓ Branch 26 taken 113 times.
✓ Branch 27 taken 211 times.
✓ Branch 28 taken 48 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
33345 switch(guysbuf[id&0xFFF].family)
20319 {
20320 //Fixme: possible enemy memory leak. (minor)
20321 case eeWALK:
20322
3/6
✓ Branch 0 taken 16941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16941 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16941 times.
✗ Branch 5 not taken.
16941 e = new eStalfos((zfix)x,(zfix)y,id,clk);
20323 16941 break;
20324
20325 case eeLEV:
20326
3/6
✓ Branch 0 taken 1097 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1097 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1097 times.
✗ Branch 5 not taken.
1097 e = new eLeever((zfix)x,(zfix)y,id,clk);
20327 1097 break;
20328
20329 case eeTEK:
20330
3/6
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2000 times.
✗ Branch 5 not taken.
2000 e = new eTektite((zfix)x,(zfix)y,id,clk);
20331 2000 break;
20332
20333 case eePEAHAT:
20334
3/6
✓ Branch 0 taken 743 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 743 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 743 times.
✗ Branch 5 not taken.
743 e = new ePeahat((zfix)x,(zfix)y,id,clk);
20335 743 break;
20336
20337 case eeZORA:
20338
3/6
✓ Branch 0 taken 1371 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1371 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1371 times.
✗ Branch 5 not taken.
1371 e = new eZora((zfix)x,(zfix)y,id,clk);
20339 1371 break;
20340
20341 case eeGHINI:
20342
3/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129 times.
✗ Branch 5 not taken.
129 e = new eGhini((zfix)x,(zfix)y,id,clk);
20343 129 break;
20344
20345 case eeKEESE:
20346
3/6
✓ Branch 0 taken 3625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3625 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3625 times.
✗ Branch 5 not taken.
3625 e = new eKeese((zfix)x,(zfix)y,id,clk);
20347 3625 break;
20348
20349 case eeWIZZ:
20350
3/6
✓ Branch 0 taken 1647 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1647 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1647 times.
✗ Branch 5 not taken.
1647 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
20351 1647 break;
20352
20353 case eePROJECTILE:
20354
3/6
✓ Branch 0 taken 2019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2019 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2019 times.
✗ Branch 5 not taken.
2019 e = new eProjectile((zfix)x,(zfix)y,id,clk);
20355 2019 break;
20356
20357 case eeWALLM:
20358
3/6
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 377 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 377 times.
✗ Branch 5 not taken.
377 e = new eWallM((zfix)x,(zfix)y,id,clk);
20359 377 break;
20360
20361 case eeAQUA:
20362
3/6
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 63 times.
✗ Branch 5 not taken.
63 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
20363 63 break;
20364
20365 case eeMOLD:
20366
6/12
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 78 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 78 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 78 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 78 times.
✓ Branch 10 taken 78 times.
✗ Branch 11 not taken.
78 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
20367 78 break;
20368
20369 case eeMANHAN:
20370
3/6
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53 times.
✗ Branch 5 not taken.
53 e = new eManhandla((zfix)x,(zfix)y,id,clk);
20371 53 break;
20372
20373 case eeGLEEOK:
20374
6/12
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 79 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 79 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 79 times.
✓ Branch 10 taken 79 times.
✗ Branch 11 not taken.
79 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
20375 79 break;
20376
20377 case eeGHOMA:
20378
3/6
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
44 e = new eGohma((zfix)x,(zfix)y,id,clk);
20379 44 break;
20380
20381 case eeLANM:
20382
6/12
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 90 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 90 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 90 times.
✓ Branch 10 taken 90 times.
✗ Branch 11 not taken.
90 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
20383 90 break;
20384
20385 case eeGANON:
20386
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 e = new eGanon((zfix)x,(zfix)y,id,clk);
20387 6 break;
20388
20389 case eeFAIRY:
20390
3/6
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 303 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 303 times.
✗ Branch 5 not taken.
303 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
20391 303 break;
20392
20393 case eeFIRE:
20394
3/6
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✗ Branch 5 not taken.
75 e = new eFire((zfix)x,(zfix)y,id,clk);
20395 75 break;
20396
20397 case eeOTHER:
20398
3/6
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1278 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1278 times.
✗ Branch 5 not taken.
1278 e = new eOther((zfix)x,(zfix)y,id,clk);
20399 1278 break;
20400
20401
20402 case eeSCRIPT01:
20403 case eeSCRIPT02:
20404 case eeSCRIPT03:
20405 case eeSCRIPT04:
20406 case eeSCRIPT05:
20407 case eeSCRIPT06:
20408 case eeSCRIPT07:
20409 case eeSCRIPT08:
20410 case eeSCRIPT09:
20411 case eeSCRIPT10:
20412 case eeSCRIPT11:
20413 case eeSCRIPT12:
20414 case eeSCRIPT13:
20415 case eeSCRIPT14:
20416 case eeSCRIPT15:
20417 case eeSCRIPT16:
20418 case eeSCRIPT17:
20419 case eeSCRIPT18:
20420 case eeSCRIPT19:
20421 case eeSCRIPT20:
20422 {
20423 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
20424 {
20425 e = new eScript((zfix)x,(zfix)y,id,clk);
20426 break;
20427 }
20428 else return 0;
20429 }
20430
20431 case eeFFRIENDLY01:
20432 case eeFFRIENDLY02:
20433 case eeFFRIENDLY03:
20434 case eeFFRIENDLY04:
20435 case eeFFRIENDLY05:
20436 case eeFFRIENDLY06:
20437 case eeFFRIENDLY07:
20438 case eeFFRIENDLY08:
20439 case eeFFRIENDLY09:
20440 case eeFFRIENDLY10:
20441 {
20442 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
20443 {
20444 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
20445 }
20446 else return 0;
20447
20448 }
20449
20450 case eeSPINTILE:
20451
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
20452 94 break;
20453
20454 // and these enemies use the misc10/misc2 value
20455 case eeROCK:
20456 {
20457
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 166 times.
196 switch(guysbuf[id&0xFFF].misc10)
20458 {
20459 case 1:
20460
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
20461 30 break;
20462
20463 166 case 0:
20464 default:
20465
3/6
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 166 times.
✗ Branch 5 not taken.
166 e = new eRock((zfix)x,(zfix)y,id,clk);
20466 166 break;
20467 }
20468
20469 196 break;
20470 }
20471
20472 case eeTRAP:
20473 {
20474
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 546 times.
665 switch(guysbuf[id&0xFFF].misc2)
20475 {
20476 case 1:
20477
3/6
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119 times.
✗ Branch 5 not taken.
119 e = new eTrap2((zfix)x,(zfix)y,id,clk);
20478 119 break;
20479
20480 546 case 0:
20481 default:
20482
3/6
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 546 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 546 times.
✗ Branch 5 not taken.
546 e = new eTrap((zfix)x,(zfix)y,id,clk);
20483 546 break;
20484 }
20485
20486 665 break;
20487 }
20488
20489 case eeDONGO:
20490 {
20491
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 111 times.
113 switch(guysbuf[id&0xFFF].misc10)
20492 {
20493 case 1:
20494
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
20495 2 break;
20496
20497 111 case 0:
20498 default:
20499
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 e = new eDodongo((zfix)x,(zfix)y,id,clk);
20500 111 break;
20501 }
20502
20503 113 break;
20504 }
20505
20506 case eeDIG:
20507 {
20508
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✓ Branch 2 taken 34 times.
211 switch(guysbuf[id&0xFFF].misc10)
20509 {
20510 case 1:
20511
3/6
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 177 times.
✗ Branch 5 not taken.
177 e = new eLilDig((zfix)x,(zfix)y,id,clk);
20512 177 break;
20513
20514 34 case 0:
20515 default:
20516
3/6
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
34 e = new eBigDig((zfix)x,(zfix)y,id,clk);
20517 34 break;
20518 }
20519
20520 211 break;
20521 }
20522
20523 case eePATRA:
20524 {
20525
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 3 times.
48 switch(guysbuf[id&0xFFF].misc10)
20526 {
20527 case 1:
20528
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
20529 {
20530
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
20531 3 break;
20532 }
20533 [[fallthrough]];
20534 45 case 0:
20535 default:
20536
3/6
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
45 e = new ePatra((zfix)x,(zfix)y,id,clk);
20537 45 break;
20538 }
20539
20540 48 break;
20541 }
20542
20543 case eeGUY:
20544 {
20545 switch(guysbuf[id&0xFFF].misc10)
20546 {
20547 case 1:
20548 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20549 break;
20550
20551 case 0:
20552 default:
20553 e = new eNPC((zfix)x,(zfix)y,id,clk);
20554 break;
20555 }
20556
20557 break;
20558 }
20559
20560 case eeNONE:
20561 if(guysbuf[id&0xFFF].misc10 ==1)
20562 {
20563 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20564 break;
20565 break;
20566 }
20567 [[fallthrough]];
20568 default:
20569
20570 return 0;
20571 }
20572
20573 33345 ret++; // Made one enemy.
20574
20575
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 33262 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 59 times.
33345 if(z && canfall(id))
20576 {
20577 59 e->z = (zfix)z;
20578 59 }
20579
20580
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 33262 times.
33345 ((enemy*)e)->ceiling = (z && canfall(id));
20581
20582
1/2
✓ Branch 0 taken 33345 times.
✗ Branch 1 not taken.
33345 if(!guys.add(e))
20583 {
20584 return 0;
20585 }
20586
20587 // add segments of segmented enemies
20588 33345 int32_t c=0;
20589
20590
6/6
✓ Branch 0 taken 32997 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 53 times.
✓ Branch 4 taken 79 times.
✓ Branch 5 taken 48 times.
33345 switch(guysbuf[id&0xFFF].family)
20591 {
20592 case eeMOLD:
20593 {
20594 78 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20595 78 id &= 0xFFF;
20596
20597
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 528 times.
✓ Branch 6 taken 450 times.
✓ Branch 7 taken 78 times.
528 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
20598 {
20599 //christ this is messy -DD
20600 450 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
20601
20602
4/8
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 450 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 450 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 450 times.
✗ Branch 7 not taken.
450 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
20603 {
20604 al_trace("Moldorm segment %d could not be created!\n",i+1);
20605
20606 for(int32_t j=0; j<i+1; j++)
20607 guys.del(guys.Count()-1);
20608
20609 return 0;
20610 }
20611
20612
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 372 times.
450 if(i>0)
20613 372 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20614
20615 450 ret++;
20616 450 }
20617
20618 78 break;
20619 }
20620
20621 case eeLANM:
20622 {
20623 90 id &= 0xFFF;
20624 90 int32_t shft = guysbuf[id].misc2;
20625 90 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20626
20627
4/8
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 90 times.
✗ Branch 7 not taken.
90 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
20628 {
20629 al_trace("Lanmola segment 1 could not be created!\n");
20630 guys.del(guys.Count()-1);
20631 return 0;
20632 }
20633
20634 90 ret++;
20635
20636
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 505 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 505 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 505 times.
✓ Branch 6 taken 415 times.
✓ Branch 7 taken 90 times.
505 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
20637 {
20638
4/8
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 415 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 415 times.
✗ Branch 7 not taken.
415 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
20639 {
20640 al_trace("Lanmola segment %d could not be created!\n",i+1);
20641
20642 for(int32_t j=0; j<i+1; j++)
20643 guys.del(guys.Count()-1);
20644
20645 return 0;
20646 }
20647
20648 415 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20649 415 ret++;
20650 415 }
20651 }
20652 90 break;
20653
20654 case eeMANHAN:
20655 53 id &= 0xFFF;
20656
20657
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 53 times.
297 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
20658 {
20659
4/8
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 244 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 244 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 244 times.
✗ Branch 7 not taken.
244 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
20660 {
20661 al_trace("Manhandla head %d could not be created!\n",i+1);
20662
20663 for(int32_t j=0; j<i+1; j++)
20664 {
20665 guys.del(guys.Count()-1);
20666 }
20667
20668 return 0;
20669 }
20670
20671 244 ret++;
20672 244 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
20673 244 }
20674
20675 53 break;
20676
20677 case eeGLEEOK:
20678 {
20679 79 id &= 0xFFF;
20680
20681
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 309 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 309 times.
✓ Branch 6 taken 230 times.
✓ Branch 7 taken 79 times.
309 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
20682 {
20683
4/8
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 230 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 230 times.
✗ Branch 7 not taken.
230 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
20684 {
20685 al_trace("Gleeok head %d could not be created!\n",i+1);
20686
20687 for(int32_t j=0; j<i+1; j++)
20688 {
20689 guys.del(guys.Count()-1);
20690 }
20691
20692 return false;
20693 }
20694
20695 230 c-=guysbuf[id].misc4;
20696 230 ret++;
20697 230 }
20698 }
20699 79 break;
20700
20701
20702 case eePATRA:
20703 {
20704 48 id &= 0xFFF;
20705 48 int32_t outeyes = 0;
20706
20707
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 378 times.
✓ Branch 3 taken 48 times.
426 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
20708 {
20709
10/22
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 360 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 360 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 360 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 360 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
378 if(!((guysbuf[id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
20710 {
20711 al_trace("Patra outer eye %d could not be created!\n",i+1);
20712
20713 for(int32_t j=0; j<i+1; j++)
20714 guys.del(guys.Count()-1);
20715
20716 return 0;
20717 }
20718 else
20719 378 outeyes++;
20720
20721 378 ret++;
20722 378 }
20723
20724
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 48 times.
136 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
20725 {
20726
4/8
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
88 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
20727 {
20728 al_trace("Patra inner eye %d could not be created!\n",i+1);
20729
20730 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
20731 guys.del(guys.Count()-1);
20732
20733 return 0;
20734 }
20735
20736 88 ret++;
20737 88 }
20738
20739 48 break;
20740 }
20741 }
20742
20743 33345 return ret;
20744 33345 }
20745
20746 737179 bool isjumper(int32_t id)
20747 {
20748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 737179 times.
737179 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20749 {
20750 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isjumper()");
20751 return false;
20752 }
20753
3/3
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 652187 times.
✓ Branch 2 taken 84988 times.
737179 switch(guysbuf[id&0xFFF].family)
20754 {
20755 case eeROCK:
20756 case eeTEK:
20757 4 return true;
20758
20759 case eeWALK:
20760
3/4
✓ Branch 0 taken 84988 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 72723 times.
84988 if(guysbuf[id&0xFFF].misc9==e9tVIRE || guysbuf[id&0xFFF].misc9==e9tPOLSVOICE) return true;
20761 72723 }
20762
20763 724910 return false;
20764 737179 }
20765
20766
20767 95002 bool isfixedtogrid(int32_t id)
20768 {
20769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95002 times.
95002 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20770 {
20771 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isfixedtogrid()");
20772 return false;
20773 }
20774
1/2
✓ Branch 0 taken 95002 times.
✗ Branch 1 not taken.
95002 switch(guysbuf[id&0xFFF].family)
20775 {
20776 case eeWALK:
20777 case eeLEV:
20778 case eeZORA:
20779 case eeDONGO:
20780 case eeGANON:
20781 case eeROCK:
20782 case eeGLEEOK:
20783 case eeAQUA:
20784 case eeLANM:
20785 return true;
20786 }
20787
20788 95002 return false;
20789 95002 }
20790
20791 // Can't fall, can have Z value.
20792 23614825 bool isflier(int32_t id)
20793 {
20794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23614825 times.
23614825 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20795 {
20796 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isflier()");
20797 return false;
20798 }
20799
2/2
✓ Branch 0 taken 21025309 times.
✓ Branch 1 taken 2589516 times.
23614825 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
20800 {
20801 case eePEAHAT:
20802 case eeKEESE:
20803 case eePATRA:
20804 case eeFAIRY:
20805 case eeGHINI:
20806
20807 // Could theoretically have their Z set by a script
20808 case eeFIRE:
20809 2589516 return true;
20810 break;
20811 }
20812
20813 21025309 return false;
20814 23614825 }
20815
20816 // Can't have Z position
20817 1194470 bool never_in_air(int32_t id)
20818 {
20819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1194470 times.
1194470 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20820 {
20821 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "never_in_air()");
20822 return false;
20823 }
20824
2/2
✓ Branch 0 taken 1187148 times.
✓ Branch 1 taken 7322 times.
1194470 switch(guysbuf[id&0xFFF].family)
20825 {
20826 case eeMANHAN:
20827 case eeMOLD:
20828 case eeLANM:
20829 case eeGLEEOK:
20830 case eeZORA:
20831 case eeLEV:
20832 case eeAQUA:
20833 case eeROCK:
20834 case eeGANON:
20835 case eeTRAP:
20836 case eePROJECTILE:
20837 case eeSPINTILE:
20838 7322 return true;
20839 }
20840
20841 1187148 return false;
20842 1194470 }
20843
20844 816006 bool canfall(int32_t id)
20845 {
20846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 816006 times.
816006 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20847 {
20848 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "canfall()");
20849 return false;
20850 }
20851
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 815984 times.
✓ Branch 2 taken 22 times.
816006 switch(guysbuf[id&0xFFF].family)
20852 {
20853 case eeGUY:
20854 {
20855
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(id < eOCTO1S)
20856 22 return false;
20857
20858 switch(guysbuf[id&0xFFF].misc10)
20859 {
20860 case 1:
20861 case 2:
20862 return true;
20863
20864 case 0:
20865 case 3:
20866 default:
20867 return false;
20868 }
20869
20870 case eeGHOMA:
20871 case eeDIG:
20872 return false;
20873 }
20874 }
20875
20876
20877
4/4
✓ Branch 0 taken 808662 times.
✓ Branch 1 taken 7322 times.
✓ Branch 2 taken 71483 times.
✓ Branch 3 taken 737179 times.
815984 return !never_in_air(id) && !isflier(id) && !isjumper(id);
20878 816006 }
20879
20880 22710262 bool enemy::enemycanfall(int32_t id, bool checkgrav)
20881 {
20882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22710262 times.
22710262 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20883 {
20884 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "enemycanfall()");
20885 return false;
20886 }
20887 //Z_scripterrlog("canfall family is %d:\n", family);
20888 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & FLAG_OBEYS_GRAV ? "true" : "false");
20889 //if ( family == eeFIRE && id >= eSTART )
20890 //{
20891 // Z_scripterrlog("eeFire\n");
20892 // return moveflags & FLAG_OBEYS_GRAV; //'Other' enemy class, used by scripts. -Z
20893 //}
20894
20895 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
20896
20897
3/3
✓ Branch 0 taken 167290 times.
✓ Branch 1 taken 21964403 times.
✓ Branch 2 taken 578569 times.
22710262 switch(guysbuf[id&0xFFF].family)
20898 {
20899 case eeGUY:
20900 {
20901
1/2
✓ Branch 0 taken 578569 times.
✗ Branch 1 not taken.
578569 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
20902 578569 return false;
20903
20904 switch(guysbuf[id&0xFFF].misc10) //I'm unsure what these specify off-hand. Needs better comments. -Z
20905 {
20906 case 1:
20907 case 2:
20908 return true;
20909
20910 case 0:
20911 case 3:
20912 default:
20913 return false;
20914 }
20915
20916 case eeGHOMA:
20917 case eeDIG:
20918 167290 return false;
20919 }
20920 }
20921
20922
2/2
✓ Branch 0 taken 16208393 times.
✓ Branch 1 taken 5756010 times.
21964403 if(!checkgrav) return true;
20923 16208393 return (moveflags & FLAG_OBEYS_GRAV);
20924
20925 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
20926 // {
20927 // if ( moveflags & FLAG_OBEYS_GRAV ) return true;
20928 // else return false;
20929 // }
20930 // else
20931 // {
20932 // return (moveflags & FLAG_OBEYS_GRAV);
20933 // }
20934 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
20935 22710262 }
20936
20937 477 void addfires()
20938 {
20939
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 233 times.
477 if(!get_bit(quest_rules,qr_NOGUYFIRES))
20940 {
20941 244 int32_t bs = get_bit(quest_rules,qr_BSZELDA);
20942 244 addguy(bs? 64: 72,64,gFIRE,-17,false);
20943 244 addguy(bs?176:168,64,gFIRE,-18,false);
20944 244 }
20945 477 }
20946
20947 10418 void loadguys()
20948 {
20949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10418 times.
10418 if(loaded_guys)
20950 return;
20951
20952 10418 loaded_guys=true;
20953
20954 10418 byte Guy=0;
20955 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
20956 // Else use mITEM and ipONETIME
20957 10418 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
20958 10418 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
20959
20960 10418 repaircharge=0;
20961 10418 adjustmagic=false;
20962 10418 learnslash=false;
20963
20964
2/2
✓ Branch 0 taken 31260 times.
✓ Branch 1 taken 10418 times.
41678 for(int32_t i=0; i<3; i++)
20965 {
20966 31260 prices[i]=0;
20967 31260 }
20968
20969 10418 hasitem=0;
20970
20971
4/4
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 9826 times.
✓ Branch 2 taken 314 times.
✓ Branch 3 taken 278 times.
10418 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
20972 {
20973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(DMaps[currdmap].flags&dmfCAVES)
20974 {
20975 278 Guy=tmpscr[1].guy;
20976 278 }
20977 278 }
20978 else
20979 {
20980 10140 Guy=tmpscr->guy;
20981
20982
4/4
✓ Branch 0 taken 9828 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 6000 times.
✓ Branch 3 taken 3828 times.
10140 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
20983 3828 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
20984 }
20985
20986 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
20987
4/4
✓ Branch 0 taken 2258 times.
✓ Branch 1 taken 8160 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 490 times.
10418 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
20988 {
20989
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 484 times.
490 if(tmpscr->room==rZELDA)
20990 {
20991 6 addguy(120,72,Guy,-15,true);
20992 6 guys.spr(0)->hxofs=1000;
20993 6 addenemy(128,96,eFIRE,-15);
20994 6 addenemy(112,96,eFIRE,-15);
20995 6 addenemy(96,120,eFIRE,-15);
20996 6 addenemy(144,120,eFIRE,-15);
20997 6 return;
20998 }
20999
21000
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 475 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2 times.
484 if(Guy!=gFAIRY || !get_bit(quest_rules,qr_NOFAIRYGUYFIRES))
21001 477 addfires();
21002
21003
2/2
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 274 times.
488 if(currscr>=128)
21004
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 267 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
281 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
21005 7 Guy=0;
21006
21007
3/6
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
488 switch(tmpscr->room)
21008 {
21009 case rSP_ITEM:
21010 case rGRUMBLE:
21011 case rBOMBS:
21012 case rARROWS:
21013 case rSWINDLE:
21014 case rMUPGRADE:
21015 case rLEARNSLASH:
21016 case rTAKEONE:
21017
8/8
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 33 times.
74 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21018 25 Guy=0;
21019
21020 114 break;
21021
21022 case rREPAIR:
21023 if (get_bit(quest_rules, qr_OLD_DOORREPAIR)) break;
21024 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21025 Guy=0;
21026
21027 break;
21028 case rRP_HC:
21029 if (get_bit(quest_rules, qr_OLD_POTION_OR_HC)) break;
21030 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21031 Guy=0;
21032
21033 break;
21034 case rMONEY:
21035 if (get_bit(quest_rules, qr_OLD_SECRETMONEY)) break;
21036 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21037 Guy=0;
21038
21039 break;
21040
21041 case rTRIFORCE:
21042 {
21043 22 int32_t tc = TriforceCount();
21044
21045
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 if(get_bit(quest_rules,qr_4TRI))
21046 {
21047
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_bit(quest_rules,qr_3TRI) && tc>=3) || tc>=4)
21048 10 Guy=0;
21049 9 }
21050 else
21051 {
21052
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 if((get_bit(quest_rules,qr_3TRI) && tc>=6) || tc>=8)
21053 11 Guy=0;
21054 }
21055 }
21056 20 break;
21057 }
21058
21059
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 435 times.
486 if(Guy)
21060 {
21061
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
435 if(Guy!=gFAIRY || !get_bit(quest_rules,qr_NOFAIRYGUYFIRES))
21062 426 blockpath=true;
21063
21064
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 168 times.
435 if(currscr<128)
21065 168 sfx(WAV_SCALE);
21066
21067
4/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 165 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 267 times.
435 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true);
21068 435 Hero.Freeze();
21069 435 }
21070 486 }
21071
2/2
✓ Branch 0 taken 9882 times.
✓ Branch 1 taken 46 times.
9928 else if(Guy==gFAIRY) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
21072 {
21073 46 sfx(WAV_SCALE);
21074 46 addguy(120,62,gFAIRY,-14,false);
21075 46 }
21076
21077 10414 loaditem();
21078
21079 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
21080 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
21081
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 10406 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 6 times.
10414 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
21082 {
21083 //setmapflag();
21084
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 6 times.
66 for(int32_t i=0; i<10; i++)
21085 60 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
21086 6 }
21087 10420 }
21088
21089 10420 void loaditem()
21090 {
21091 10420 byte Item = 0;
21092
21093
2/2
✓ Branch 0 taken 9828 times.
✓ Branch 1 taken 592 times.
10420 if(currscr<128)
21094 {
21095 9828 Item=tmpscr->item;
21096
21097
4/4
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 9340 times.
✓ Branch 2 taken 8884 times.
✓ Branch 3 taken 944 times.
9828 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21098 {
21099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 944 times.
944 if(tmpscr->flags8&fSECRETITEM)
21100 hasitem=8;
21101
2/2
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 469 times.
944 else if(tmpscr->flags&fITEM)
21102 475 hasitem=1;
21103
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 448 times.
469 else if(tmpscr->enemyflags&efCARRYITEM)
21104 21 hasitem=4; // Will be set to 2 by roaming_item
21105 else
21106
2/4
✓ Branch 0 taken 448 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 448 times.
✗ Branch 3 not taken.
896 items.add(new item((zfix)tmpscr->itemx,
21107
7/14
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 445 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 448 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 448 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 448 times.
✗ Branch 13 not taken.
448 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_bit(quest_rules, qr_NOITEMOFFSET)?0:1),
21108
6/10
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 445 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 445 times.
✗ Branch 9 not taken.
448 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
21109
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 405 times.
448 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
21110 448 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
21111 944 }
21112 9828 }
21113
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 314 times.
592 else if(!(DMaps[currdmap].flags&dmfCAVES))
21114 {
21115
4/6
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 310 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
315 if((!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
21116
4/4
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 205 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 108 times.
314 && (currscr==128 || !get_bit(quest_rules,qr_ITEMSINPASSAGEWAYS)))
21117 {
21118 109 Item=tmpscr[1].catchall;
21119
21120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(Item)
21121
2/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 109 times.
✗ Branch 3 not taken.
218 items.add(new item((zfix)tmpscr->itemx,
21122
4/14
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 109 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 109 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 109 times.
✗ Branch 13 not taken.
109 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_bit(quest_rules, qr_NOITEMOFFSET)?0:1),
21123
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 109 times.
✗ Branch 9 not taken.
109 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
21124 109 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
21125 109 }
21126 314 }
21127 10420 }
21128
21129 446 void never_return(int32_t index)
21130 {
21131
2/2
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 74 times.
446 if(!get_bit(quest_rules,qr_KILLALL))
21132 74 goto doit;
21133
21134
2/2
✓ Branch 0 taken 1256 times.
✓ Branch 1 taken 178 times.
1434 for(int32_t i=0; i<guys.Count(); i++)
21135
4/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 194 times.
✓ Branch 3 taken 275 times.
1256 if(((((enemy*)guys.spr(i))->d->flags)&guy_neverret) && i!=index)
21136 {
21137 194 goto dontdoit;
21138 178 }
21139
21140 doit:
21141 252 setmapflag(mNEVERRET);
21142 dontdoit:
21143 446 return;
21144 }
21145
21146 22658 bool slowguy(int32_t id)
21147 {
21148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22658 times.
22658 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
21149 {
21150 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "slowguy()");
21151 return false;
21152 }
21153 //return (guysbuf[id].step<100);
21154
2/2
✓ Branch 0 taken 19386 times.
✓ Branch 1 taken 3272 times.
22658 switch(id)
21155 {
21156 case eOCTO1S:
21157 case eOCTO2S:
21158 case eOCTO1F:
21159 case eOCTO2F:
21160 case eLEV1:
21161 case eLEV2:
21162 case eROCK:
21163 case eBOULDER:
21164 3272 return true;
21165 }
21166
21167 19386 return false;
21168 22658 }
21169
21170 25796 bool ok2add(int32_t id)
21171 {
21172
2/4
✓ Branch 0 taken 25796 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25796 times.
25796 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
21173 {
21174 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "oktoadd()");
21175 return false;
21176 }
21177
4/4
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 25452 times.
✓ Branch 2 taken 158 times.
✓ Branch 3 taken 186 times.
25796 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_neverret))
21178 186 return false;
21179
21180
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25500 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 78 times.
25610 switch(guysbuf[id].family)
21181 {
21182 // I added a special case for shooters because having traps on the same screen
21183 // was preventing them from spawning due to TMPNORET. This means they will
21184 // never stay dead, though, so it may not be the best solution. - Saf
21185 case eePROJECTILE:
21186 32 return true;
21187
21188
21189 case eeDIG:
21190 {
21191
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 33 times.
78 switch(guysbuf[id].misc10)
21192 {
21193 case 1:
21194
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 32 times.
45 if(!get_bit(quest_rules,qr_NOTMPNORET))
21195 13 return !getmapflag(mTMPNORET);
21196
21197 32 return true;
21198
21199 33 case 0:
21200 default:
21201 33 return true;
21202 }
21203 }
21204 case eeGANON:
21205 case eeTRAP:
21206 if ((guysbuf[id].family == eeGANON && !get_bit(quest_rules, qr_CAN_PLACE_GANON))
21207 || (guysbuf[id].family == eeTRAP && !get_bit(quest_rules, qr_CAN_PLACE_TRAPS))) return false;
21208 [[fallthrough]];
21209 default:
21210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25500 times.
25500 if (guysbuf[id].flags2&guy_ignoretmpnr) return true;
21211 25500 break;
21212 }
21213
21214
2/2
✓ Branch 0 taken 8758 times.
✓ Branch 1 taken 16742 times.
25500 if(!get_bit(quest_rules,qr_NOTMPNORET))
21215 16742 return !getmapflag(mTMPNORET);
21216
21217 8758 return true;
21218 25796 }
21219
21220 224297 void activate_fireball_statue(int32_t pos)
21221 {
21222
3/4
✓ Branch 0 taken 93017 times.
✓ Branch 1 taken 131280 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93017 times.
224297 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
21223 {
21224 131280 return;
21225 }
21226
21227 93017 int32_t cx=-1000, cy=-1000;
21228 93017 int32_t x = (pos&15)<<4;
21229 93017 int32_t y = pos&0xF0;
21230
21231 93017 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
21232
21233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93017 times.
93017 if(!isfixedtogrid(statueID))
21234 {
21235
2/2
✓ Branch 0 taken 939 times.
✓ Branch 1 taken 92078 times.
93017 if(ctype==cL_STATUE)
21236 {
21237 939 cx=x+4;
21238 939 cy=y+7;
21239 939 }
21240
2/2
✓ Branch 0 taken 966 times.
✓ Branch 1 taken 91112 times.
92078 else if(ctype==cR_STATUE)
21241 {
21242 966 cx=x-8;
21243 966 cy=y-1;
21244 966 }
21245
2/2
✓ Branch 0 taken 91032 times.
✓ Branch 1 taken 80 times.
91112 else if(ctype==cC_STATUE)
21246 {
21247 80 cx=x;
21248 80 cy=y;
21249 80 }
21250 93017 }
21251 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
21252 {
21253 cx=x;
21254 cy=y;
21255 }
21256
21257
2/2
✓ Branch 0 taken 91032 times.
✓ Branch 1 taken 1985 times.
93017 if(cx!=-1000) // No point creating it if this is false
21258 {
21259
2/2
✓ Branch 0 taken 6033 times.
✓ Branch 1 taken 1985 times.
8018 for(int32_t j=0; j<guys.Count(); j++)
21260 {
21261
3/4
✓ Branch 0 taken 1128 times.
✓ Branch 1 taken 4905 times.
✓ Branch 2 taken 1128 times.
✗ Branch 3 not taken.
6033 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
21262 {
21263 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
21264 return; // No point deleting it. A script might be toying with it in some way.
21265 else
21266 guys.del(j);
21267 }
21268 6033 }
21269
21270 1985 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
21271 1985 }
21272 224297 }
21273
21274 10370 void activate_fireball_statues()
21275 {
21276
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 9856 times.
10370 if(!(tmpscr->enemyflags&efFIREBALLS))
21277 {
21278 9856 return;
21279 }
21280
21281
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 90464 times.
90978 for(int32_t i=0; i<176; i++)
21282 {
21283 90464 activate_fireball_statue(i);
21284 90464 }
21285 10370 }
21286
21287 10370 void load_default_enemies()
21288 {
21289 10370 wallm_load_clk=frame-80;
21290 10370 int32_t Id=0;
21291
21292
2/2
✓ Branch 0 taken 9505 times.
✓ Branch 1 taken 865 times.
10370 if(tmpscr->enemyflags&efZORA)
21293 {
21294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if(zoraID>=0)
21295 865 addenemy(-16, -16, zoraID, 0);
21296 865 }
21297
21298
2/2
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 71 times.
10370 if(tmpscr->enemyflags&efTRAP4)
21299 {
21300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(cornerTrapID>=0)
21301 {
21302 71 addenemy(32, 32, cornerTrapID, -14);
21303 71 addenemy(208, 32, cornerTrapID, -14);
21304 71 addenemy(32, 128, cornerTrapID, -14);
21305 71 addenemy(208, 128, cornerTrapID, -14);
21306 71 }
21307 71 }
21308
21309
2/2
✓ Branch 0 taken 114070 times.
✓ Branch 1 taken 10370 times.
124440 for(int32_t y=0; y<176; y+=16)
21310 {
21311
2/2
✓ Branch 0 taken 1825120 times.
✓ Branch 1 taken 114070 times.
1939190 for(int32_t x=0; x<256; x+=16)
21312 {
21313 1825120 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
21314 1825120 int32_t cflag = MAPFLAG(x, y);
21315 1825120 int32_t cflag_i = MAPCOMBOFLAG(x, y);
21316
21317
4/6
✓ Branch 0 taken 1825120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825069 times.
✓ Branch 3 taken 51 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1825069 times.
1825120 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
21318 {
21319
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 41 times.
51 if(trapLOSHorizontalID>=0)
21320 41 addenemy(x, y, trapLOSHorizontalID, -14);
21321 51 }
21322
4/6
✓ Branch 0 taken 1825069 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825053 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1825053 times.
1825069 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
21323 {
21324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(trapLOSVerticalID>=0)
21325 16 addenemy(x, y, trapLOSVerticalID, -14);
21326 16 }
21327
4/6
✓ Branch 0 taken 1825053 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1824914 times.
✓ Branch 3 taken 139 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1824914 times.
1825053 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
21328 {
21329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if(trapLOS4WayID>=0)
21330 {
21331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if(addenemy(x, y, trapLOS4WayID, -14))
21332 139 guys.spr(guys.Count()-1)->dummy_int[1]=2;
21333 139 }
21334 139 }
21335
21336
4/6
✓ Branch 0 taken 1824914 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1824866 times.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1824866 times.
1824914 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
21337 {
21338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(trapConstantHorizontalID>=0)
21339 48 addenemy(x, y, trapConstantHorizontalID, -14);
21340 48 }
21341
4/6
✓ Branch 0 taken 1824866 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1824795 times.
✓ Branch 3 taken 71 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1824795 times.
1824866 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
21342 {
21343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(trapConstantVerticalID>=0)
21344 71 addenemy(x, y, trapConstantVerticalID, -14);
21345 71 }
21346
21347
1/2
✓ Branch 0 taken 1825120 times.
✗ Branch 1 not taken.
1825120 if(ctype==cSPINTILE1)
21348 {
21349 // Awaken spinning tile
21350 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
21351 }
21352 1825120 }
21353 114070 }
21354
21355
2/2
✓ Branch 0 taken 10335 times.
✓ Branch 1 taken 35 times.
10370 if(tmpscr->enemyflags&efTRAP2)
21356 {
21357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(centerTrapID>=-1)
21358 {
21359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(addenemy(64, 80, centerTrapID, -14))
21360 35 guys.spr(guys.Count()-1)->dummy_int[1]=1;
21361
21362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(addenemy(176, 80, centerTrapID, -14))
21363 35 guys.spr(guys.Count()-1)->dummy_int[1]=1;
21364 35 }
21365 35 }
21366
21367
2/2
✓ Branch 0 taken 10323 times.
✓ Branch 1 taken 47 times.
10370 if(tmpscr->enemyflags&efROCKS)
21368 {
21369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(rockID>=0)
21370 {
21371 47 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21372 47 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21373 47 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21374 47 }
21375 47 }
21376
21377 10370 activate_fireball_statues();
21378 10370 }
21379
21380 12916299 void update_slope_combopos(int32_t lyr, int32_t pos)
21381 {
21382
2/4
✓ Branch 0 taken 12916299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12916299 times.
12916299 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
21383 12916299 mapscr* s = FFCore.tempScreens[lyr];
21384 12916299 newcombo const& cmb = combobuf[s->data[pos]];
21385
21386 12916299 auto id = (176*lyr)+pos;
21387 12916299 auto it = slopes.find(id);
21388
21389 12916299 bool wasSlope = it!=slopes.end();
21390 12916299 bool isSlope = cmb.type == cSLOPE;
21391
21392
3/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 12916229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
12916299 if(isSlope && !wasSlope)
21393 {
21394 70 slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos);
21395 70 }
21396
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12916229 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12916229 else if(wasSlope && !isSlope)
21397 {
21398 slopes.erase(it);
21399 }
21400 12916299 }
21401 10426 void update_slope_comboposes()
21402 {
21403
2/2
✓ Branch 0 taken 72982 times.
✓ Branch 1 taken 10426 times.
83408 for(auto lyr = 0; lyr < 7; ++lyr)
21404 {
21405
2/2
✓ Branch 0 taken 12844832 times.
✓ Branch 1 taken 72982 times.
12917814 for(auto pos = 0; pos < 176; ++pos)
21406 12844832 update_slope_combopos(lyr,pos);
21407 72982 }
21408 10426 }
21409
21410 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
21411 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
21412 133833 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
21413 {
21414 133833 delete_fireball_shooter(s, pos);
21415 133833 }
21416
21417 //Placeholder in case we need it.
21418 void screen_ffc_modify_preroutine(word index)
21419 {
21420 return;
21421 }
21422
21423 // Everything that must be done after we change a screen's combo to another combo. -L
21424 133833 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
21425 {
21426 133833 s->valid |= mVALID;
21427 133833 activate_fireball_statue(pos);
21428
21429
2/2
✓ Branch 0 taken 133739 times.
✓ Branch 1 taken 94 times.
133833 if(combobuf[s->data[pos]].type==cSPINTILE1)
21430 {
21431 // Awaken spinning tile
21432 94 awaken_spinning_tile(s,pos);
21433 94 }
21434 133833 int32_t lyr = -1;
21435
2/2
✓ Branch 0 taken 87953 times.
✓ Branch 1 taken 45880 times.
133833 if(s == tmpscr) lyr = 0;
21436
2/2
✓ Branch 0 taken 62366 times.
✓ Branch 1 taken 468438 times.
530804 else for(size_t q = 0; q < 6; ++q)
21437 {
21438
2/2
✓ Branch 0 taken 25587 times.
✓ Branch 1 taken 442851 times.
468438 if(s == tmpscr2+q)
21439 {
21440 25587 lyr = q+1;
21441 25587 break;
21442 }
21443 442851 }
21444
2/2
✓ Branch 0 taken 62366 times.
✓ Branch 1 taken 71467 times.
133833 if(lyr > -1)
21445 71467 update_slope_combopos(lyr,pos);
21446 133833 }
21447
21448 2170809 void screen_ffc_modify_postroutine(word index)
21449 {
21450 2170809 ffcdata& ff = tmpscr->ffcs[index];
21451 2170809 newcombo const& cmb = combobuf[ff.getData()];
21452
21453 2170809 auto id = (176*7)+int32_t(index);
21454 2170809 auto it = slopes.find(id);
21455
21456 2170809 bool wasSlope = it!=slopes.end();
21457
2/2
✓ Branch 0 taken 2170707 times.
✓ Branch 1 taken 102 times.
2170809 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffCHANGER);
21458
3/4
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 2170717 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 92 times.
2170809 if(isSlope && !wasSlope)
21459 {
21460 92 slopes.try_emplace(id, nullptr, &ff, id);
21461 92 }
21462
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2170716 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2170717 else if(wasSlope && !isSlope)
21463 {
21464 1 slopes.erase(it);
21465 1 }
21466
21467 2170809 tmpscr->ffcCountMarkDirty();
21468 2170809 }
21469
21470 void screen_combo_modify_pre(int32_t cid)
21471 {
21472 for(auto lyr = 0; lyr < 7; ++lyr)
21473 {
21474 mapscr* t = FFCore.tempScreens[lyr];
21475 for(int32_t i = 0; i < 176; i++)
21476 {
21477 if(t->data[i] == cid)
21478 {
21479 screen_combo_modify_preroutine(t,i);
21480 }
21481 }
21482 }
21483 }
21484 void screen_combo_modify_post(int32_t cid)
21485 {
21486 for(auto lyr = 0; lyr < 7; ++lyr)
21487 {
21488 mapscr* t = FFCore.tempScreens[lyr];
21489 for(int32_t i = 0; i < 176; i++)
21490 {
21491 if(t->data[i] == cid)
21492 {
21493 screen_combo_modify_postroutine(t,i);
21494 }
21495 }
21496 }
21497 for(word ind = 0; ind < MAXFFCS; ++ind)
21498 {
21499 if(tmpscr->ffcs[ind].getData() == cid)
21500 screen_ffc_modify_postroutine(ind);
21501 }
21502 }
21503
21504 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
21505 {
21506
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
21507 94 }
21508
21509
21510 // It stands for next_side_pos
21511 9789 void nsp(bool random)
21512 // moves sle_x and sle_y to the next position
21513 {
21514
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 6528 times.
9789 if(random)
21515 {
21516
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
21517 {
21518 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
21519 1634 sle_y = (zc_oldrand()%10)*16;
21520 1634 }
21521 else
21522 {
21523 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
21524 1627 sle_x = (zc_oldrand()%15)*16;
21525 }
21526
21527 3261 return;
21528 }
21529
21530
2/2
✓ Branch 0 taken 4944 times.
✓ Branch 1 taken 1584 times.
6528 if(sle_x==0)
21531 {
21532
2/2
✓ Branch 0 taken 1442 times.
✓ Branch 1 taken 142 times.
1584 if(sle_y<160)
21533 1442 sle_y+=16;
21534 else
21535 142 sle_x+=16;
21536 1584 }
21537
2/2
✓ Branch 0 taken 2062 times.
✓ Branch 1 taken 2882 times.
4944 else if(sle_y==160)
21538 {
21539
2/2
✓ Branch 0 taken 1929 times.
✓ Branch 1 taken 133 times.
2062 if(sle_x<240)
21540 1929 sle_x+=16;
21541 else
21542 133 sle_y-=16;
21543 2062 }
21544
2/2
✓ Branch 0 taken 1250 times.
✓ Branch 1 taken 1632 times.
2882 else if(sle_x==240)
21545 {
21546
2/2
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 120 times.
1250 if(sle_y>0)
21547 1130 sle_y-=16;
21548 else
21549 120 sle_x-=16;
21550 1250 }
21551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1632 times.
1632 else if(sle_y==0)
21552 {
21553
1/2
✓ Branch 0 taken 1632 times.
✗ Branch 1 not taken.
1632 if(sle_x>0)
21554 1632 sle_x-=16;
21555 else
21556 sle_y+=16;
21557 1632 }
21558 9789 }
21559
21560 1844 int32_t next_side_pos(bool random)
21561 // moves sle_x and sle_y to the next available position
21562 // returns the direction the enemy should face
21563 {
21564 bool blocked;
21565 1844 int32_t c=0;
21566
21567 1844 do
21568 {
21569
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 9664 times.
9789 nsp(c>35 ? false : random);
21570
3/4
✓ Branch 0 taken 1843 times.
✓ Branch 1 taken 7946 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1843 times.
11632 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
21571
1/2
✓ Branch 0 taken 1843 times.
✗ Branch 1 not taken.
1843 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
21572
2/4
✓ Branch 0 taken 1843 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1843 times.
✗ Branch 3 not taken.
1843 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
21573
2/4
✓ Branch 0 taken 1843 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1843 times.
1843 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
21574 1843 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
21575
21576
2/2
✓ Branch 0 taken 9788 times.
✓ Branch 1 taken 1 times.
9789 if(++c>50)
21577 1 return -1;
21578
2/2
✓ Branch 0 taken 7945 times.
✓ Branch 1 taken 1843 times.
9788 }
21579 9788 while(blocked);
21580
21581 1843 int32_t dir=0;
21582
21583
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 541 times.
1843 if(sle_x==0) dir=right;
21584
21585
2/2
✓ Branch 0 taken 1370 times.
✓ Branch 1 taken 473 times.
1843 if(sle_y==0) dir=down;
21586
21587
2/2
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 532 times.
1843 if(sle_x==240) dir=left;
21588
21589
1/2
✓ Branch 0 taken 1843 times.
✗ Branch 1 not taken.
1843 if(sle_y==168) dir=up;
21590
21591 1843 return dir;
21592 1844 }
21593
21594 bool can_side_load(int32_t id)
21595 {
21596 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
21597 {
21598 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "can_side_load()");
21599 return false;
21600 }
21601 switch(guysbuf[id].family) //id&0x0FFF)
21602 {
21603 //case eTEK1:
21604 //case eTEK2:
21605 //case eTEK3:
21606 //case eLEV1:
21607 //case eLEV2:
21608 //case eLEV3:
21609 //case eRAQUAM:
21610 //case eLAQUAM:
21611 //case eDODONGO:
21612 //case eMANHAN:
21613 //case eGLEEOK1:
21614 //case eGLEEOK2:
21615 //case eGLEEOK3:
21616 //case eGLEEOK4:
21617 //case eDIG1:
21618 //case eDIG3:
21619 //case eGOHMA1:
21620 //case eGOHMA2:
21621 //case eCENT1:
21622 //case eCENT2:
21623 //case ePATRA1:
21624 //case ePATRA2:
21625 //case eGANON:
21626 //case eMANHAN2:
21627 //case eCEILINGM: later
21628 //case eFLOORM: later
21629 //case ePATRABS:
21630 //case ePATRAL2:
21631 //case ePATRAL3:
21632 //case eGLEEOK1F:
21633 //case eGLEEOK2F:
21634 //case eGLEEOK3F:
21635 //case eGLEEOK4F:
21636 //case eDODONGOBS:
21637 //case eDODONGOF:
21638 //case eGOHMA3:
21639 //case eGOHMA4:
21640 //case eSHOOTMAGIC:
21641 //case eSHOOTROCK:
21642 //case eSHOOTSPEAR:
21643 //case eSHOOTSWORD:
21644 //case eSHOOTFLAME:
21645 //case eSHOOTFLAME2:
21646 //case eSHOOTFBALL:
21647 case eeTEK:
21648 case eeLEV:
21649 case eeAQUA:
21650 case eeDONGO:
21651 case eeMANHAN:
21652 case eeGLEEOK:
21653 case eeDIG:
21654 case eeGHOMA:
21655 case eeLANM:
21656 case eePATRA:
21657 case eeGANON:
21658 case eePROJECTILE:
21659 return false;
21660 break;
21661 }
21662
21663 return true;
21664 }
21665
21666 static bool script_sle = false;
21667 static int32_t sle_pattern = 0;
21668 void script_side_load_enemies()
21669 {
21670 if(script_sle || sle_clk) return;
21671 sle_cnt = 0;
21672 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21673 ++sle_cnt;
21674 script_sle = true;
21675 sle_pattern = tmpscr->pattern;
21676 sle_clk = 0;
21677 }
21678
21679 40988 void side_load_enemies()
21680 {
21681
3/4
✓ Branch 0 taken 40988 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40430 times.
✓ Branch 3 taken 558 times.
40988 if(!script_sle && sle_clk==0)
21682 {
21683 558 sle_pattern = tmpscr->pattern;
21684 558 sle_cnt = 0;
21685 558 int32_t guycnt = 0;
21686 558 int16_t s = (currmap<<7)+currscr;
21687 558 bool beenhere=false;
21688 558 bool reload=true;
21689 558 bool unbeatablereload = true;
21690
21691 558 load_default_enemies();
21692
21693
2/2
✓ Branch 0 taken 3348 times.
✓ Branch 1 taken 558 times.
3906 for(int32_t i=0; i<6; i++)
21694
2/2
✓ Branch 0 taken 3181 times.
✓ Branch 1 taken 167 times.
3515 if(visited[i]==s)
21695 167 beenhere=true;
21696
21697
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 391 times.
558 if(!beenhere)
21698 {
21699 391 visited[vhead]=s;
21700 391 vhead = (vhead+1)%6;
21701 391 }
21702
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 39 times.
167 else if(game->guys[s]==0)
21703 {
21704 39 sle_cnt=0;
21705 39 reload=false;
21706 39 }
21707
21708
2/2
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 175 times.
558 if(reload)
21709 {
21710 175 sle_cnt = game->guys[s];
21711
21712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175 times.
175 if((get_bit(quest_rules, qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
21713
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 175 times.
175 || sle_cnt==0)
21714 {
21715
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 970 times.
✓ Branch 2 taken 797 times.
✓ Branch 3 taken 175 times.
972 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21716 797 ++sle_cnt;
21717 175 }
21718
3/4
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 391 times.
519 if (!beenhere && get_bit(quest_rules, qr_UNBEATABLES_DONT_KEEP_DEAD))
21719 {
21720 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
21721 {
21722 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
21723 {
21724 unbeatablereload = false;
21725 }
21726 }
21727 if (unbeatablereload)
21728 {
21729 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21730 {
21731 ++sle_cnt;
21732 }
21733 }
21734 }
21735 519 }
21736
21737
4/4
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 344 times.
✓ Branch 2 taken 344 times.
✓ Branch 3 taken 214 times.
902 if((get_bit(quest_rules,qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
21738 {
21739 688 sle_cnt = 0;
21740
21741
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
688 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21742 ++sle_cnt;
21743 }
21744
21745
2/2
✓ Branch 0 taken 1805 times.
✓ Branch 1 taken 214 times.
2019 for(int32_t i=0; i<sle_cnt; i++)
21746 1805 ++guycnt;
21747
21748 214 game->guys[s] = guycnt;
21749 214 }
21750
21751
2/2
✓ Branch 0 taken 38800 times.
✓ Branch 1 taken 1844 times.
40644 if((++sle_clk+8)%24 == 0)
21752 {
21753 1844 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
21754
21755
4/4
✓ Branch 0 taken 1843 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 1657 times.
1844 if(dir==-1 || tooclose(sle_x,sle_y,32))
21756 {
21757 187 return;
21758 }
21759
21760 1657 int32_t enemy_slot=guys.Count();
21761
21762
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1657 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1657 times.
1657 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
21763 sle_cnt--;
21764
21765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1657 times.
1657 if(sle_cnt > 0)
21766 {
21767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1657 times.
1657 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
21768 {
21769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1657 times.
1657 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
21770 {
21771 1657 guys.spr(enemy_slot)->dir = dir;
21772 1657 }
21773 1657 }
21774 1657 }
21775 1657 }
21776
21777
2/2
✓ Branch 0 taken 39964 times.
✓ Branch 1 taken 493 times.
40457 if(sle_cnt<=0)
21778 {
21779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 493 times.
493 if(script_sle)
21780 script_sle = false;
21781 493 else loaded_enemies=true;
21782 493 sle_clk = 0;
21783 493 }
21784 40644 }
21785
21786 1089148 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
21787 {
21788
21789
4/4
✓ Branch 0 taken 990346 times.
✓ Branch 1 taken 98802 times.
✓ Branch 2 taken 98802 times.
✓ Branch 3 taken 1089148 times.
1089148 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
21790 {
21791 //zprint2("is_starting_pos(), tmpscr->enemy[i] is: %d\n", tmpscr->enemy[i]);
21792 197604 return false; //never 0, never OoB.
21793 }
21794 // No corner enemies
21795
6/6
✓ Branch 0 taken 929967 times.
✓ Branch 1 taken 159181 times.
✓ Branch 2 taken 38423 times.
✓ Branch 3 taken 968390 times.
✓ Branch 4 taken 109780 times.
✓ Branch 5 taken 87824 times.
1089148 if((x==0 || x==240) && (y==0 || y==160))
21796
21797 197604 return false;
21798
21799 //Is a no spawn combo...
21800
3/4
✓ Branch 0 taken 968386 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 968386 times.
968390 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
21801 4 return false;
21802
21803 // No enemies in dungeon walls
21804
10/10
✓ Branch 0 taken 627393 times.
✓ Branch 1 taken 340993 times.
✓ Branch 2 taken 555873 times.
✓ Branch 3 taken 71520 times.
✓ Branch 4 taken 484353 times.
✓ Branch 5 taken 71520 times.
✓ Branch 6 taken 398529 times.
✓ Branch 7 taken 85824 times.
✓ Branch 8 taken 85824 times.
✓ Branch 9 taken 312705 times.
968386 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
21805 314688 return false;
21806
21807 // Too close
21808
4/4
✓ Branch 0 taken 68466 times.
✓ Branch 1 taken 585232 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 68465 times.
653698 if(tooclose(x,y,40) && t<11)
21809 68465 return false;
21810
21811 // Can't fly onto it?
21812
4/4
✓ Branch 0 taken 113422 times.
✓ Branch 1 taken 471811 times.
✓ Branch 2 taken 33807 times.
✓ Branch 3 taken 16220 times.
635260 if(isflier(tmpscr->enemy[i])&&
21813
2/2
✓ Branch 0 taken 113413 times.
✓ Branch 1 taken 9 times.
113422 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
21814
2/2
✓ Branch 0 taken 50027 times.
✓ Branch 1 taken 63386 times.
113413 (_walkflag(x,y+8,2)&&!get_bit(quest_rules,qr_WALLFLIERS))))
21815 16229 return false;
21816
21817 // Can't jump onto it?
21818 if
21819 (
21820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83813 times.
652817 guysbuf[tmpscr->enemy[i]].family==eeTEK
21821
21822
2/2
✓ Branch 0 taken 83813 times.
✓ Branch 1 taken 485191 times.
569004 &&
21823 (
21824
1/2
✓ Branch 0 taken 83813 times.
✗ Branch 1 not taken.
83813 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
21825
1/2
✓ Branch 0 taken 83813 times.
✗ Branch 1 not taken.
83813 COMBOTYPE(x+8,y+8)==cNOENEMY||
21826
1/2
✓ Branch 0 taken 83813 times.
✗ Branch 1 not taken.
83813 ispitfall(x+8,y+8)||
21827
1/2
✓ Branch 0 taken 83813 times.
✗ Branch 1 not taken.
83813 MAPFLAG(x+8,y+8)==mfNOENEMY||
21828 83813 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
21829 )
21830 )
21831 {
21832 return false;
21833 }
21834
21835 // Other off-limit combos
21836
6/6
✓ Branch 0 taken 471811 times.
✓ Branch 1 taken 97193 times.
✓ Branch 2 taken 387998 times.
✓ Branch 3 taken 83813 times.
✓ Branch 4 taken 226567 times.
✓ Branch 5 taken 161431 times.
957002 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
21837
2/2
✓ Branch 0 taken 229849 times.
✓ Branch 1 taken 158149 times.
387998 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
21838 387998 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
21839 161431 return false;
21840
21841 // Don't ever generate enemies on these combos!
21842
3/4
✓ Branch 0 taken 407274 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 407274 times.
407573 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
21843 299 return false;
21844
21845 //BS Dodongos need at least 2 spaces.
21846
4/4
✓ Branch 0 taken 936 times.
✓ Branch 1 taken 406338 times.
✓ Branch 2 taken 934 times.
✓ Branch 3 taken 2 times.
407274 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].misc10==1))
21847 {
21848
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
21849 ((x>224)||_walkflag(x+16,y+8, 2))&&
21850 ((y<16) ||_walkflag(x, y-8, 2))&&
21851 ((y>144)||_walkflag(x, y+24,2)))
21852 {
21853 return false;
21854 }
21855 2 }
21856
21857 407274 return true;
21858 990346 }
21859
21860 47740 bool is_ceiling_pattern(int32_t i)
21861 {
21862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47740 times.
47740 return (i==pCEILING || i==pCEILINGR);
21863 }
21864
21865 5489 int32_t placeenemy(int32_t i)
21866 {
21867 5489 std::map<int32_t, int32_t> freeposcache;
21868 5489 int32_t frees = 0;
21869
21870
2/2
✓ Branch 0 taken 60379 times.
✓ Branch 1 taken 5489 times.
65868 for(int32_t y=0; y<176; y+=16)
21871 {
21872
2/2
✓ Branch 0 taken 966064 times.
✓ Branch 1 taken 60379 times.
1026443 for(int32_t x=0; x<256; x+=16)
21873 {
21874
3/4
✓ Branch 0 taken 966064 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 390104 times.
✓ Branch 3 taken 575960 times.
966064 if(is_starting_pos(i,x,y,0))
21875 {
21876
1/2
✓ Branch 0 taken 390104 times.
✗ Branch 1 not taken.
390104 freeposcache[frees++] = (y&0xF0)+(x>>4);
21877 390104 }
21878 966064 }
21879 60379 }
21880
21881
2/2
✓ Branch 0 taken 5488 times.
✓ Branch 1 taken 1 times.
5489 if(frees > 0)
21882
2/4
✓ Branch 0 taken 5488 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5488 times.
✗ Branch 3 not taken.
5488 return freeposcache[zc_oldrand()%frees];
21883
21884 1 return -1;
21885 5489 }
21886
21887 24140 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
21888 {
21889 24140 bool placed=false;
21890 24140 int32_t t=-1;
21891
21892 // First: enemy combo flags
21893
2/2
✓ Branch 0 taken 258297 times.
✓ Branch 1 taken 22659 times.
280956 for(int32_t sy=0; sy<176; sy+=16)
21894 {
21895
2/2
✓ Branch 0 taken 4121988 times.
✓ Branch 1 taken 256816 times.
4378804 for(int32_t sx=0; sx<256; sx+=16)
21896 {
21897 4121988 int32_t cflag = MAPFLAG(sx, sy);
21898 4121988 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
21899
21900
2/4
✓ Branch 0 taken 4121988 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4121988 times.
✗ Branch 3 not taken.
4121988 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
21901 {
21902 if(!ok2add(tmpscr->enemy[i]))
21903 {
21904 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
21905 }
21906 else
21907 {
21908 addenemy(sx,
21909 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
21910 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
21911
21912 ++guycnt;
21913
21914 placed=true;
21915 goto placed_enemy;
21916 }
21917 }
21918
21919
4/4
✓ Branch 0 taken 4120507 times.
✓ Branch 1 taken 1481 times.
✓ Branch 2 taken 4120507 times.
✓ Branch 3 taken 1481 times.
4121988 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
21920 {
21921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1481 times.
1481 if(!ok2add(tmpscr->enemy[i]))
21922 {
21923 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
21924 }
21925 else
21926 {
21927 2962 addenemy(sx,
21928
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1481 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1481 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
21929
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1481 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1481 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
21930
21931 1481 ++guycnt;
21932
21933 1481 placed=true;
21934 1481 goto placed_enemy;
21935 }
21936 }
21937 4120507 }
21938 256816 }
21939
21940 // Next: enemy pattern
21941
6/8
✓ Branch 0 taken 4892 times.
✓ Branch 1 taken 17767 times.
✓ Branch 2 taken 17192 times.
✓ Branch 3 taken 5467 times.
✓ Branch 4 taken 17192 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 17192 times.
22659 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
21942 {
21943 17192 do
21944 {
21945
21946 // NES positions
21947 24304 pos%=9;
21948 24304 x=stx[loadside][pos];
21949 24304 y=sty[loadside][pos];
21950 24304 ++pos;
21951 24304 ++t;
21952
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 17192 times.
41496 }
21953
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 24282 times.
24304 while((t< 20) && !is_starting_pos(i,x,y,t));
21954 17192 }
21955
21956
4/4
✓ Branch 0 taken 17192 times.
✓ Branch 1 taken 5467 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 17170 times.
22659 if(t<0 || t >= 20) // above enemy pattern failed
21957 {
21958 // Final chance: find a random position anywhere onscreen
21959 5489 int32_t randpos = placeenemy(i);
21960
21961
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5488 times.
5489 if(randpos>-1)
21962 {
21963 5488 x=(randpos&15)<<4;
21964 5488 y= randpos&0xF0;
21965 5488 }
21966 else // All opportunities failed - abort
21967 {
21968 1 return;
21969 }
21970 5488 }
21971
21972 {
21973 22658 int32_t c=0;
21974 22658 c=clk;
21975
21976
2/2
✓ Branch 0 taken 3272 times.
✓ Branch 1 taken 19386 times.
22658 if(!slowguy(tmpscr->enemy[i]))
21977 19386 ++fastguys;
21978
2/2
✓ Branch 0 taken 521 times.
✓ Branch 1 taken 2751 times.
3272 else if(fastguys>0)
21979 521 c=-15*(i-fastguys+2);
21980 else
21981 2751 c=-15*(i+1);
21982
21983
4/6
✓ Branch 0 taken 1059 times.
✓ Branch 1 taken 21599 times.
✓ Branch 2 taken 1059 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1059 times.
22658 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
21984 {
21985 // Special case for blue leevers
21986
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1059 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1059 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].misc1==1)
21987 c=-15*(i+1);
21988 else
21989 1059 c=-15;
21990 1059 }
21991
21992
2/2
✓ Branch 0 taken 22389 times.
✓ Branch 1 taken 269 times.
22658 if(!ok2add(tmpscr->enemy[i]))
21993 {
21994
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
269 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
21995 269 }
21996 else
21997 {
21998
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22389 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22389 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
21999 {
22000
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 22306 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
44778 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
22001
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 22306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
22389 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
22002
22003 22389 ++guycnt;
22004 22389 }
22005 }
22006
22007 22658 placed=true;
22008 22658 } // if(t < 20)
22009
22010 placed_enemy:
22011
22012 // I don't like this, but it seems to work...
22013 static bool foundCarrier;
22014
22015
2/2
✓ Branch 0 taken 18461 times.
✓ Branch 1 taken 5678 times.
24139 if(i==0)
22016 5678 foundCarrier=false;
22017
22018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24139 times.
24139 if(placed)
22019 {
22020
4/4
✓ Branch 0 taken 5678 times.
✓ Branch 1 taken 18461 times.
✓ Branch 2 taken 5539 times.
✓ Branch 3 taken 139 times.
24139 if(i==0 && tmpscr->enemyflags&efLEADER)
22021 {
22022 139 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
22023
22024
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 7 times.
139 if(index!=-1)
22025 {
22026 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
22027
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
132 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_bit(quest_rules, qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
22028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(index!=-1)
22029 {
22030 132 ((enemy*)guys.spr(index))->leader = true;
22031 132 }
22032 132 }
22033 139 }
22034
22035
4/4
✓ Branch 0 taken 24078 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 24057 times.
✓ Branch 3 taken 21 times.
24139 if(!foundCarrier && hasitem&(4|2))
22036 {
22037 21 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
22038
22039
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesntcount)==0)
22040 {
22041 21 ((enemy*)guys.spr(index))->itemguy = true;
22042 21 foundCarrier=true;
22043 21 }
22044 21 }
22045 24139 }
22046 24140 }
22047
22048 bool scriptloadenemies()
22049 {
22050 loaded_enemies = true;
22051 if(script_sle || sle_clk) return false;
22052 if(tmpscr->pattern==pNOSPAWN) return false;
22053
22054 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
22055 {
22056 script_side_load_enemies();
22057 return true;
22058 }
22059
22060 int32_t pos=zc_oldrand()%9;
22061 int32_t clk=-15,x=0,y=0,fastguys=0;
22062 int32_t i=0,guycnt=0;
22063 int32_t loadcnt = 10;
22064
22065 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
22066 {
22067 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
22068
22069 --clk;
22070 }
22071 return true;
22072 }
22073
22074 5141578 void loadenemies()
22075 {
22076
3/4
✓ Branch 0 taken 5141578 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40430 times.
✓ Branch 3 taken 5101148 times.
5141578 if(script_sle || sle_clk)
22077 {
22078 40430 side_load_enemies();
22079 40430 return;
22080 }
22081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5101148 times.
5101148 if(tmpscr->pattern==pNOSPAWN) return;
22082
2/2
✓ Branch 0 taken 5090760 times.
✓ Branch 1 taken 10388 times.
5101148 if(loaded_enemies)
22083 5090760 return;
22084
22085 // check if it's the dungeon boss and it has been beaten before
22086
4/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 10312 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 18 times.
10388 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
22087 {
22088 18 loaded_enemies = true;
22089 18 return;
22090 }
22091
22092
4/4
✓ Branch 0 taken 10053 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 9812 times.
10370 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
22093 {
22094 558 side_load_enemies();
22095 558 return;
22096 }
22097
22098 9812 loaded_enemies=true;
22099
22100 // do enemies that are always loaded
22101 9812 load_default_enemies();
22102
22103 // dungeon basements
22104
22105 static byte dngn_enemy_x[4] = {32,96,144,208};
22106
22107
2/2
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 9220 times.
9812 if(currscr>=128)
22108 {
22109
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 314 times.
592 if(DMaps[currdmap].flags&dmfCAVES) return;
22110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 314 times.
314 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
22111 {
22112 for(int32_t i=0; i<10; i++)
22113 {
22114 if ( tmpscr->enemy[i] )
22115 {
22116 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
22117 }
22118 }
22119 }
22120 else
22121 {
22122
2/2
✓ Branch 0 taken 1256 times.
✓ Branch 1 taken 314 times.
1570 for(int32_t i=0; i<4; i++)
22123
2/2
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 292 times.
1256 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
22124 }
22125 314 return;
22126 }
22127
22128 // check if it's been long enough to reload all enemies
22129
22130 9220 int32_t loadcnt = 10;
22131 9220 int16_t s = (currmap<<7)+currscr;
22132 9220 bool beenhere = false;
22133 9220 bool reload = true;
22134 9220 bool unbeatablereload = true;
22135
22136
2/2
✓ Branch 0 taken 55320 times.
✓ Branch 1 taken 9220 times.
64540 for(int32_t i=0; i<6; i++)
22137
2/2
✓ Branch 0 taken 52550 times.
✓ Branch 1 taken 2770 times.
58090 if(visited[i]==s)
22138 2770 beenhere = true;
22139
22140
2/2
✓ Branch 0 taken 2770 times.
✓ Branch 1 taken 6450 times.
9220 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
22141 {
22142 6450 visited[vhead]=s; //If not, it adds it to the array,
22143 6450 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
22144 6450 }
22145
2/2
✓ Branch 0 taken 1119 times.
✓ Branch 1 taken 1651 times.
2770 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
22146 {
22147 1651 loadcnt = 0; //It will tell it not to load any enemies,
22148 1651 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
22149 1651 }
22150
22151
2/2
✓ Branch 0 taken 1651 times.
✓ Branch 1 taken 7569 times.
9220 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
22152 {
22153 7569 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
22154
22155
2/4
✓ Branch 0 taken 2355 times.
✓ Branch 1 taken 5214 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7569 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
22156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2355 times.
2355 (get_bit(quest_rules, qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
22157 5214 loadcnt = 10; //That means all enemies need to be respawned.
22158
3/4
✓ Branch 0 taken 6450 times.
✓ Branch 1 taken 1119 times.
✓ Branch 2 taken 6450 times.
✗ Branch 3 not taken.
7569 if (!beenhere && get_bit(quest_rules, qr_UNBEATABLES_DONT_KEEP_DEAD))
22159 {
22160 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
22161 {
22162 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
22163 {
22164 unbeatablereload = false;
22165 }
22166 }
22167 if (unbeatablereload)
22168 {
22169 loadcnt = 10;
22170 }
22171 }
22172 7569 }
22173
22174
3/4
✓ Branch 0 taken 9220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 9174 times.
9220 if((get_bit(quest_rules,qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
22175 46 loadcnt = 10; //All enemies also need to be respawned.
22176
22177 9220 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
22178 9220 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
22179 9220 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
22180
22181
4/4
✓ Branch 0 taken 4169 times.
✓ Branch 1 taken 29191 times.
✓ Branch 2 taken 24140 times.
✓ Branch 3 taken 9220 times.
33360 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
22182 {
22183 24140 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
22184
22185 24140 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
22186 24140 }
22187
22188 9220 game->guys[s] = guycnt;
22189 //} //if(true)
22190 5141578 }
22191 98 void moneysign()
22192 {
22193 98 additem(48,108,iRupy,ipDUMMY);
22194 // textout(scrollbuf,zfont,"X",64,112,CSET(0)+1);
22195 98 set_clip_state(pricesdisplaybuf, 0);
22196 98 textout_ex(pricesdisplaybuf,zfont,"X",64,112,CSET(0)+1,-1);
22197 98 }
22198
22199 685 void putprices(bool sign)
22200 {
22201
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 679 times.
685 if(fadeclk > 0) return;
22202 // refresh what's under the prices
22203 // for(int32_t i=5; i<12; i++)
22204 // putcombo(scrollbuf,i<<4,112,tmpscr->data[112+i],tmpscr->cpage);
22205
22206 679 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
22207 679 int32_t step=32;
22208 679 int32_t x=80;
22209
22210
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 555 times.
679 if(prices[2]==0)
22211 {
22212 555 step<<=1;
22213
22214
2/2
✓ Branch 0 taken 535 times.
✓ Branch 1 taken 20 times.
555 if(prices[1]==0)
22215 {
22216 535 x=112;
22217 535 }
22218 555 }
22219
22220
2/2
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 2037 times.
2716 for(int32_t i=0; i<3; i++)
22221 {
22222 // Kind of stupid, but it works: 100000 is used to indicate that an item
22223 // has a price of zero rather than there being no item.
22224 // 100000 isn't a valid price, so this doesn't cause problems.
22225
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
2037 if(prices[i]!=0 && prices[i]<100000)
22226 {
22227 char buf[8];
22228 432 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
22229
22230 432 int32_t l=(int32_t)strlen(buf);
22231 432 set_clip_state(pricesdisplaybuf, 0);
22232
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 415 times.
432 textout_ex(pricesdisplaybuf,zfont,buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
22233 432 }
22234
22235 2037 x+=step;
22236 2037 }
22237 685 }
22238
22239 // Setting up special rooms
22240 // Also called when the Letter is used successfully.
22241 444 void setupscreen()
22242 {
22243 444 boughtsomething=false;
22244 444 int32_t t=currscr<128?0:1;
22245 444 word str=tmpscr[t].str;
22246
22247 // Prices are already set to 0 in dowarp()
22248
13/15
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 35 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 10 times.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 13 times.
444 switch(tmpscr[t].room)
22249 {
22250 case rSP_ITEM: // special item
22251 76 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
22252 76 break;
22253
22254 case rINFO: // pay for info
22255 {
22256 8 int32_t count = 0;
22257 8 int32_t base = 88;
22258 8 int32_t step = 5;
22259
22260 8 moneysign();
22261
22262
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 24 times.
32 for(int32_t i=0; i<3; i++)
22263 {
22264
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(QMisc.info[tmpscr[t].catchall].str[i])
22265 {
22266 24 ++count;
22267 24 }
22268 else
22269 break;
22270 24 }
22271
22272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(count)
22273 {
22274
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(count==1)
22275 {
22276 base = 88+32;
22277 }
22278
22279
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(count==2)
22280 {
22281 step = 6;
22282 }
22283
22284
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 8 times.
32 for(int32_t i=0; i < count; i++)
22285 {
22286 24 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
22287 24 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
22288 24 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
22289
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(prices[i]==0)
22290 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22291 24 int32_t itemid = current_item_id(itype_wealthmedal);
22292
22293
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if(itemid>=0 && prices[i]!=100000)
22294 {
22295 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22296 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22297 else
22298 prices[i]-=itemsbuf[itemid].misc1;
22299 prices[i]=vbound(prices[i], -99999, 0);
22300 if(prices[i]==0)
22301 prices[i]=100000;
22302 }
22303
22304
2/6
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
22305 prices[i]=-1;
22306 24 }
22307 8 }
22308
22309 8 break;
22310 }
22311
22312 case rMONEY: // secret money
22313 35 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
22314 35 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22315 35 break;
22316
22317 case rGAMBLE: // gambling
22318 5 prices[0]=prices[1]=prices[2]=-10;
22319 5 moneysign();
22320 5 additem(88,89,iRupy,ipMONEY+ipDUMMY);
22321 5 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22322 5 additem(120,89,iRupy,ipMONEY+ipDUMMY);
22323 5 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22324 5 additem(152,89,iRupy,ipMONEY+ipDUMMY);
22325 5 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
22326 5 break;
22327
22328 case rREPAIR: // door repair
22329
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
22330 // }
22331 12 repaircharge=tmpscr[t].catchall;
22332 12 break;
22333
22334 case rMUPGRADE: // upgrade magic
22335 1 adjustmagic=true;
22336 1 break;
22337
22338 case rLEARNSLASH: // learn slash attack
22339 1 learnslash=true;
22340 1 break;
22341
22342 case rRP_HC: // heart container or red potion
22343 10 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
22344 10 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22345 10 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
22346 10 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22347 10 break;
22348
22349 case rP_SHOP: // potion shop
22350
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 17 times.
21 if(current_item(itype_letter)<i_letter_used)
22351 {
22352 4 str=0;
22353 4 break;
22354 }
22355
22356 [[fallthrough]];
22357 case rTAKEONE: // take one
22358 case rSHOP: // shop
22359 {
22360 86 int32_t count = 0;
22361 86 int32_t base = 88;
22362 86 int32_t step = 5;
22363
22364
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 85 times.
86 if(tmpscr[t].room != rTAKEONE)
22365 85 moneysign();
22366
22367 //count and align the stuff
22368
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 254 times.
329 for(int32_t i=0; i<3; ++i)
22369 {
22370
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 11 times.
254 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
22371 {
22372 243 ++count;
22373 243 }
22374 else
22375 {
22376 11 break;
22377 }
22378 243 }
22379
22380
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 4 times.
86 if(count==1)
22381 {
22382 4 base = 88+32;
22383 4 }
22384
22385
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 7 times.
86 if(count==2)
22386 {
22387 7 step = 6;
22388 7 }
22389
22390
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 86 times.
329 for(int32_t i=0; i<count; i++)
22391 {
22392 243 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
22393 243 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
22394
22395
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 241 times.
243 if(tmpscr[t].room != rTAKEONE)
22396 {
22397 241 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
22398
1/2
✓ Branch 0 taken 241 times.
✗ Branch 1 not taken.
241 if(prices[i]==0)
22399 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22400 241 int32_t itemid = current_item_id(itype_wealthmedal);
22401
22402
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 241 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
241 if(itemid>=0 && prices[i]!=100000)
22403 {
22404 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22405 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22406 else
22407 prices[i]+=itemsbuf[itemid].misc1;
22408 prices[i]=vbound(prices[i], 0, 99999);
22409 if(prices[i]==0)
22410 prices[i]=100000;
22411 }
22412
22413
2/4
✓ Branch 0 taken 241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 241 times.
✗ Branch 3 not taken.
241 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
22414 prices[i]=1;
22415 241 }
22416 243 }
22417
22418 86 break;
22419 }
22420 case rBOTTLESHOP: // bottle shop
22421 {
22422 int32_t count = 0;
22423 int32_t base = 88;
22424 int32_t step = 5;
22425
22426 moneysign();
22427 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
22428 //count and align the stuff
22429 for(int32_t i=0; i<3; ++i)
22430 {
22431 if(bst.fill[count] != 0)
22432 {
22433 ++count;
22434 }
22435 else
22436 {
22437 break;
22438 }
22439 }
22440
22441 if(count==1)
22442 {
22443 base = 88+32;
22444 }
22445
22446 if(count==2)
22447 {
22448 step = 6;
22449 }
22450
22451 for(int32_t i=0; i<count; i++)
22452 {
22453 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
22454 //{ Setup dummy item
22455 item* curItem = ((item*)items.spr(items.Count()-1));
22456 curItem->PriceIndex = i;
22457 newcombo const& cmb = combobuf[bst.comb[i]];
22458 curItem->o_tile = cmb.o_tile;
22459 curItem->o_cset = bst.cset[i];
22460 curItem->cs = curItem->o_cset;
22461 curItem->tile = cmb.o_tile;
22462 curItem->o_speed = cmb.speed;
22463 curItem->o_delay = 0;
22464 curItem->frames = cmb.frames;
22465 curItem->flip = cmb.flip;
22466 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
22467 curItem->pstring = 0;
22468 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
22469 curItem->flash = false;
22470 curItem->twohand = false;
22471 curItem->anim = true;
22472 curItem->hxsz=1;
22473 curItem->hyofs=4;
22474 curItem->hysz=12;
22475 curItem->script=0;
22476 curItem->txsz=1;
22477 curItem->tysz=1;
22478 //}
22479
22480 prices[i] = bst.price[i];
22481 if(prices[i]==0)
22482 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22483 int32_t itemid = current_item_id(itype_wealthmedal);
22484
22485 if(itemid>=0 && prices[i]!=100000)
22486 {
22487 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22488 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22489 else
22490 prices[i]+=itemsbuf[itemid].misc1;
22491 prices[i]=vbound(prices[i], 0, 99999);
22492 if(prices[i]==0)
22493 prices[i]=100000;
22494 }
22495
22496 if((bst.price[i])>1 && prices[i]<1)
22497 prices[i]=1;
22498 }
22499
22500 break;
22501 }
22502
22503 case rBOMBS: // more bombs
22504 4 additem(120,89,iRupy,ipDUMMY+ipMONEY);
22505 4 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22506 4 prices[0]=-tmpscr[t].catchall;
22507 4 break;
22508
22509 case rARROWS: // more arrows
22510 additem(120,89,iRupy,ipDUMMY+ipMONEY);
22511 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22512 prices[0]=-tmpscr[t].catchall;
22513 break;
22514
22515 case rSWINDLE: // leave heart container or money
22516 13 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
22517 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22518 13 prices[0]=-1;
22519 13 additem(152,89,iRupy,ipDUMMY+ipMONEY);
22520 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22521 13 prices[1]=-tmpscr[t].catchall;
22522 13 break;
22523
22524 }
22525
22526
3/4
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 440 times.
444 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
22527 {
22528 4 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
22529 4 int32_t itemid = current_item_id(itype_wealthmedal);
22530
22531
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(itemid >= 0)
22532 {
22533 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22534 prices[i]*=(itemsbuf[itemid].misc1/100.0);
22535 else
22536 prices[i]+=itemsbuf[itemid].misc1;
22537 }
22538
22539
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(tmpscr[t].catchall>1 && prices[i]>-1)
22540 prices[i]=-1;
22541 4 }
22542
22543 444 putprices(false);
22544
22545
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 23 times.
444 if(str)
22546 {
22547 421 donewmsg(str);
22548 421 }
22549 else
22550 {
22551 23 Hero.unfreeze();
22552 }
22553 444 }
22554
22555 // Increments msgptr and returns the control code argument pointed at.
22556 630 word grab_next_argument()
22557 {
22558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630 times.
630 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
22559 630 byte val=MsgStrings[msgstr].s[++msgptr]-1;
22560 630 word ret=val;
22561
22562 // If an argument is succeeded by 255, then it's a three-byte argument -
22563 // between 254 and 65535 (or whatever the maximum actually is)
22564
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
22565
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
22566 {
22567 val=MsgStrings[msgstr].s[msgptr+2];
22568 word next=val;
22569 ret += 254*next;
22570 msgptr+=2;
22571 }
22572
22573 630 return ret;
22574 630 }
22575
22576 enum
22577 {
22578 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
22579 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
22580
22581 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
22582
22583 MNU_DATA_MAX
22584 };
22585 struct menu_choice
22586 {
22587 int32_t x, y;
22588 int32_t pos;
22589 int32_t upos, dpos, lpos, rpos;
22590 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
22591 {}
22592 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
22593 int32_t dpos, int32_t lpos, int32_t rpos)
22594 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
22595 {}
22596 };
22597 static int32_t msg_menu_data[MNU_DATA_MAX];
22598 static bool do_run_menu = false;
22599 bool do_end_str = false;
22600 static bool wait_advance = false;
22601 29 static std::map<int32_t, menu_choice> menu_options;
22602 11832 void clr_msg_data()
22603 {
22604 11832 do_end_str = false;
22605 11832 wait_advance = false;
22606 11832 do_run_menu = false;
22607 11832 menu_options.clear();
22608 11832 memset(msg_menu_data, 0, sizeof(msg_menu_data));
22609 11832 }
22610
22611 static bool doing_name_insert = false;
22612 static char namebuf[9] = {0};
22613 static char* nameptr = NULL;
22614 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
22615 bool runMenuCursor()
22616 {
22617 clear_bitmap(msg_menu_bmp_buf);
22618 if(!menu_options.size())
22619 {
22620 msg_menu_data[MNU_CHOSEN] = 0;
22621 return true; //end menu
22622 }
22623 int32_t pos = msg_menu_data[MNU_CHOSEN];
22624 //If the cursor is at an invalid pos, find the first pos >= 0...
22625 if(menu_options.find(pos) == menu_options.end())
22626 {
22627 pos = 0;
22628 while(menu_options.find(pos) == menu_options.end())
22629 ++pos;
22630 }
22631 menu_choice* ch = &menu_options[pos];
22632
22633 bool pressed = true;
22634 if(rUp()) pos = ch->upos;
22635 else if(rDown()) pos = ch->dpos;
22636 else if(rLeft()) pos = ch->lpos;
22637 else if(rRight()) pos = ch->rpos;
22638 else pressed = false;
22639
22640 if(pressed)
22641 msg_menu_data[MNU_TIMER] = 1;
22642
22643 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 5);
22644 bool held = false;
22645 if(hold_input)
22646 {
22647 held = true;
22648 if(Up()) pos = ch->upos;
22649 else if(Down()) pos = ch->dpos;
22650 else if(Left()) pos = ch->lpos;
22651 else if(Right()) pos = ch->rpos;
22652 else held = false;
22653 }
22654 //If the cursor is at an invalid pos, find the first pos >= 0...
22655 if(menu_options.find(pos) == menu_options.end())
22656 {
22657 pos = 0;
22658 while(menu_options.find(pos) == menu_options.end())
22659 ++pos;
22660 }
22661 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
22662 sfx(MsgStrings[msgstr].sfx);
22663
22664 ch = &menu_options[pos];
22665 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
22666 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
22667 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
22668 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
22669
22670 msg_menu_data[MNU_CHOSEN] = pos;
22671
22672 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
22673 {
22674 rAbtn(); //Eat
22675 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
22676 }
22677
22678 bool ret = (pressed || held) ? false : rAbtn();
22679 //Eat inputs
22680 rUp(); rDown(); rLeft(); rRight(); rAbtn();
22681
22682 if(ret)
22683 menu_options.clear();
22684
22685 return ret;
22686 //false if pos changed this frame; no confirming while moving the cursor!
22687 }
22688
22689 96906 bool bottom_margin_clip()
22690 {
22691 97206 return !get_bit(quest_rules, qr_OLD_STRING_EDITOR_MARGINS)
22692
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 96606 times.
96906 && cursor_y >= (msg_h + (get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
22693 }
22694
22695 42445 bool parsemsgcode()
22696 {
22697
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 42033 times.
42445 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
22698 42033 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
22699
4/36
✗ Branch 0 not taken.
✓ Branch 1 taken 41703 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 301 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
42033 switch(c)
22700 {
22701 case MSGC_NEWLINE:
22702 {
22703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
22704 1 ssc_tile_hei = ssc_tile_hei_buf;
22705 1 ssc_tile_hei_buf = -1;
22706 1 cursor_y += thei + MsgStrings[msgstr].vspace;
22707 1 cursor_x=msg_margins[left];
22708 1 return true;
22709 }
22710
22711 case MSGC_COLOUR:
22712 {
22713 301 int32_t cset = (grab_next_argument());
22714 301 msgcolour = CSET(cset)+(grab_next_argument());
22715 301 return true;
22716 }
22717
22718 case MSGC_SHDCOLOR:
22719 {
22720 int32_t cset = (grab_next_argument());
22721 msg_shdcol = CSET(cset)+(grab_next_argument());
22722 return true;
22723 }
22724 case MSGC_SHDTYPE:
22725 {
22726 msg_shdtype = grab_next_argument();
22727 return true;
22728 }
22729
22730 case MSGC_SPEED:
22731 {
22732 28 msgspeed=grab_next_argument();
22733 28 return true;
22734 }
22735
22736 case MSGC_CTRUP:
22737 {
22738 int32_t a1 = grab_next_argument();
22739 int32_t a2 = grab_next_argument();
22740 game->change_counter(a2, a1);
22741 return true;
22742 }
22743
22744 case MSGC_CTRDN:
22745 {
22746 int32_t a1 = grab_next_argument();
22747 int32_t a2 = grab_next_argument();
22748 game->change_counter(-a2, a1);
22749 return true;
22750 }
22751
22752 case MSGC_CTRSET:
22753 {
22754 int32_t a1 = grab_next_argument();
22755 int32_t a2 = grab_next_argument();
22756 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
22757 return true;
22758 }
22759
22760 case MSGC_CTRUPPC:
22761 case MSGC_CTRDNPC:
22762 case MSGC_CTRSETPC:
22763 {
22764 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
22765 int32_t counter = grab_next_argument();
22766 int32_t amount = grab_next_argument();
22767 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
22768
22769 if(code==MSGC_CTRDNPC)
22770 amount*=-1;
22771
22772 if(code==MSGC_CTRSETPC)
22773 game->set_counter(amount, counter);
22774 else
22775 game->change_counter(amount, counter);
22776
22777 return true;
22778 }
22779
22780 case MSGC_GIVEITEM:
22781 {
22782 int32_t itemID = grab_next_argument();
22783
22784 getitem(itemID, true);
22785 if ( !item_doscript[itemID] && (((unsigned)itemID) < 256) )
22786 {
22787 itemScriptData[itemID].Clear();
22788 memset(item_stack[itemID], 0xFFFF, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
22789 if ( (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) ) item_doscript[itemID] = 1;
22790 }
22791 return true;
22792 }
22793
22794
22795 case MSGC_WARP:
22796 {
22797 int32_t dmap = grab_next_argument();
22798 int32_t scrn = grab_next_argument();
22799 int32_t dx = grab_next_argument();
22800 int32_t dy = grab_next_argument();
22801 int32_t wfx = grab_next_argument();
22802 int32_t sfx = grab_next_argument();
22803 if(dx >= MAX_SCC_ARG) dx = -1;
22804 if(dy >= MAX_SCC_ARG) dy = -1;
22805 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, warpFlagDONTKILLMUSIC, 0);
22806 return true;
22807 }
22808
22809 case MSGC_SETSCREEND:
22810 {
22811 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
22812 int32_t screen = grab_next_argument();
22813 int32_t reg = grab_next_argument();
22814 int32_t val = grab_next_argument();
22815 FFCore.set_screen_d(screen + dmap, reg, val);
22816 return true;
22817 }
22818 case MSGC_TAKEITEM:
22819 {
22820 int32_t itemID = grab_next_argument();
22821 if ( item_doscript[itemID] )
22822 {
22823 item_doscript[itemID] = 4; //Val of 4 means 'clear stack and quit'
22824 }
22825 takeitem(itemID);
22826 if ( game->forced_bwpn == itemID )
22827 {
22828 game->forced_bwpn = -1;
22829 } //not else if! -Z
22830 if ( game->forced_awpn == itemID )
22831 {
22832 game->forced_awpn = -1;
22833 }
22834 if ( game->forced_xwpn == itemID )
22835 {
22836 game->forced_xwpn = -1;
22837 } //not else if! -Z
22838 if ( game->forced_ywpn == itemID )
22839 {
22840 game->forced_ywpn = -1;
22841 }
22842 verifyBothWeapons();
22843 return true;
22844 }
22845
22846 case MSGC_SFX:
22847 {
22848 sfx((int32_t)grab_next_argument(),128);
22849 return true;
22850 }
22851
22852 case MSGC_MIDI:
22853 {
22854 int32_t music = (int32_t)(grab_next_argument());
22855
22856 if(music==0)
22857 music_stop();
22858 else
22859 jukebox(music+(ZC_MIDI_COUNT-1));
22860
22861 return true;
22862 }
22863
22864 case MSGC_NAME:
22865 {
22866 doing_name_insert = true;
22867 sprintf(namebuf, "%s", game->get_name());
22868 nameptr = namebuf;
22869 return true;
22870 }
22871
22872 case MSGC_DRAWTILE:
22873 {
22874 int32_t tl = grab_next_argument();
22875 int32_t cs = grab_next_argument();
22876 int32_t t_wid = grab_next_argument();
22877 int32_t t_hei = grab_next_argument();
22878 int32_t fl = grab_next_argument();
22879
22880 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
22881 {
22882 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
22883 ssc_tile_hei = ssc_tile_hei_buf;
22884 ssc_tile_hei_buf = -1;
22885 cursor_y += thei + MsgStrings[msgstr].vspace;
22886 if(bottom_margin_clip()) return true;
22887 cursor_x=msg_margins[left];
22888 }
22889
22890 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
22891 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
22892 cursor_x += MsgStrings[msgstr].hspace + t_wid;
22893 return true;
22894 }
22895
22896 case MSGC_GOTOIFRAND:
22897 {
22898 int32_t odds = (int32_t)(grab_next_argument());
22899
22900 if(!odds || !(zc_oldrand()%odds))
22901 goto switched;
22902
22903 (void)grab_next_argument();
22904 return true;
22905 }
22906
22907 case MSGC_GOTOIFGLOBAL:
22908 {
22909 int32_t arg = (int32_t)grab_next_argument();
22910 int32_t d = zc_min(7,arg);
22911 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
22912 arg = (int32_t)grab_next_argument();
22913
22914 if(game->screen_d[s][d] >= arg)
22915 goto switched;
22916
22917 (void)grab_next_argument();
22918 return true;
22919 }
22920
22921 case MSGC_CHANGEPORTRAIT:
22922 {
22923 return true; //not implemented
22924 }
22925
22926 case MSGC_GOTOIFCREEND:
22927 {
22928 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
22929 int32_t screen = grab_next_argument();
22930 int32_t reg = grab_next_argument();
22931 int32_t val = grab_next_argument();
22932 //int32_t nxtstr = grab_next_argument();
22933 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
22934 {
22935 goto switched;
22936 }
22937 (void)grab_next_argument();
22938 return true;
22939 }
22940
22941 case MSGC_GOTOIF:
22942 {
22943 int32_t it = (int32_t)grab_next_argument();
22944
22945 if(unsigned(it)<MAXITEMS && game->item[it])
22946 goto switched;
22947
22948 (void)grab_next_argument();
22949 return true;
22950 }
22951
22952 case MSGC_GOTOIFCTR:
22953 {
22954 if(game->get_counter(grab_next_argument())>=grab_next_argument())
22955 goto switched;
22956
22957 (void)grab_next_argument();
22958 return true;
22959 }
22960
22961 case MSGC_GOTOIFCTRPC:
22962 {
22963 int32_t counter = grab_next_argument();
22964 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
22965
22966 if(game->get_counter(counter)>=amount)
22967 goto switched;
22968
22969 (void)grab_next_argument();
22970 return true;
22971 }
22972
22973 case MSGC_GOTOIFTRICOUNT:
22974 {
22975 if(TriforceCount() >= (int32_t)(grab_next_argument()))
22976 goto switched;
22977
22978 (void)grab_next_argument();
22979 return true;
22980 }
22981
22982 case MSGC_GOTOIFTRI:
22983 {
22984 int32_t lev = (int32_t)(grab_next_argument());
22985
22986 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
22987 goto switched;
22988
22989 (void)grab_next_argument();
22990 return true;
22991 }
22992
22993 case MSGC_SETUPMENU:
22994 {
22995 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
22996 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
22997 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
22998 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
22999 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
23000 return true;
23001 }
23002
23003 case MSGC_MENUCHOICE:
23004 {
23005 int32_t pos = grab_next_argument();
23006 int32_t upos = grab_next_argument();
23007 int32_t dpos = grab_next_argument();
23008 int32_t lpos = grab_next_argument();
23009 int32_t rpos = grab_next_argument();
23010 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
23011 {
23012 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23013 ssc_tile_hei = ssc_tile_hei_buf;
23014 ssc_tile_hei_buf = -1;
23015 cursor_y += thei + MsgStrings[msgstr].vspace;
23016 if(bottom_margin_clip()) break;
23017 cursor_x=msg_margins[left];
23018 }
23019
23020 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
23021 upos, dpos, lpos, rpos);
23022
23023 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
23024 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
23025 return true;
23026 }
23027
23028 case MSGC_RUNMENU:
23029 {
23030 msg_menu_data[MNU_CHOSEN] = 0;
23031 msg_menu_data[MNU_CAN_CONFIRM] = 0;
23032 if(menu_options.size() < 1)
23033 return true;
23034 do_run_menu = true;
23035 return true;
23036 }
23037
23038 case MSGC_GOTOMENUCHOICE:
23039 {
23040 int32_t choice = grab_next_argument();
23041 if(msg_menu_data[MNU_CHOSEN] == choice)
23042 goto switched;
23043 (void)grab_next_argument();
23044 return true;
23045 }
23046
23047 case MSGC_ENDSTRING:
23048 {
23049 do_end_str = true;
23050 return true;
23051 }
23052 case MSGC_WAIT_ADVANCE:
23053 {
23054 wait_advance = true;
23055 linkedmsgclk = 51;
23056 return true;
23057 }
23058 case MSGC_TRIGSECRETS:
23059 {
23060 bool perm = (bool)grab_next_argument();
23061 hidden_entrance(0, true, false, -8);
23062 if(perm)
23063 setmapflag(mSECRET);
23064 return true;
23065 }
23066 case MSGC_SETSCREENSTATE:
23067 {
23068 int32_t flag = int32_t(grab_next_argument());
23069 if(unsigned(flag)>=mMAXIND)
23070 {
23071 Z_error("SCC 133: Flag %d is invalid\n", flag);
23072 return true;
23073 }
23074 bool state = bool(grab_next_argument());
23075 if(state)
23076 setmapflag(1<<flag);
23077 else
23078 unsetmapflag(1<<flag,true);
23079 return true;
23080 }
23081 case MSGC_SETSCREENSTATER:
23082 {
23083 int32_t map = (int32_t)grab_next_argument();
23084 int32_t scrid = (int32_t)grab_next_argument();
23085 if(map < 1 || map > map_count)
23086 {
23087 Z_error("SCC 134: Map %d is invalid\n", map);
23088 return true;
23089 }
23090 if(unsigned(scrid)>=0x80)
23091 {
23092 Z_error("SCC 134: Screen %d is invalid\n", scrid);
23093 return true;
23094 }
23095
23096 int32_t flag = int32_t(grab_next_argument());
23097 if(unsigned(flag)>=mMAXIND)
23098 {
23099 Z_error("SCC 134: Flag %d is invalid\n", flag);
23100 return true;
23101 }
23102 bool state = bool(grab_next_argument());
23103 if(state)
23104 setmapflag(mapind(map,scrid),1<<flag);
23105 else
23106 unsetmapflag(mapind(map,scrid),1<<flag,true);
23107 return true;
23108 }
23109 switched:
23110 int32_t lev = (int32_t)(grab_next_argument());
23111 if(lev && get_bit(quest_rules, qr_SCC_GOTO_RESPECTS_CONTFLAG)
23112 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
23113 {
23114 msgstr=lev;
23115 msgpos=msgptr=0;
23116 msgfont=setmsgfont();
23117 }
23118 else donewmsg(lev);
23119 msgptr--; // To counteract it being incremented after this routine is called.
23120 putprices(false);
23121 return true;
23122 }
23123
23124 41703 return false;
23125 42445 }
23126
23127 // Wraps the message string... probably.
23128 41300 void wrapmsgstr(char *s3)
23129 {
23130 41300 int32_t j=0;
23131
23132
2/2
✓ Branch 0 taken 9679 times.
✓ Branch 1 taken 31621 times.
41300 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23133 {
23134
2/2
✓ Branch 0 taken 2081 times.
✓ Branch 1 taken 7598 times.
9679 if(msgspace)
23135 {
23136 2081 char c = MsgStrings[msgstr].s[msgptr];
23137
4/6
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 1786 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1786 times.
✗ Branch 5 not taken.
2081 if(c != ' ' && c >= 32 && c <= 126)
23138 {
23139
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9806 times.
✓ Branch 2 taken 8026 times.
✓ Branch 3 taken 1786 times.
9812 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
23140 {
23141
3/4
✓ Branch 0 taken 7734 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7734 times.
8026 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
23142 8026 }
23143
23144 1786 s3[j] = 0;
23145 1786 msgspace = false;
23146 1786 }
23147 else
23148 {
23149 295 s3[0] = c;
23150 295 s3[1] = 0;
23151 }
23152 2081 }
23153 else
23154 {
23155 7598 s3[0] = MsgStrings[msgstr].s[msgptr];
23156 7598 s3[1] = 0;
23157
23158
2/2
✓ Branch 0 taken 5948 times.
✓ Branch 1 taken 1650 times.
7598 if(s3[0] == ' ') msgspace=true;
23159 }
23160 9679 }
23161 else
23162 {
23163 31621 s3[0] = MsgStrings[msgstr].s[msgptr];
23164 31621 s3[1] = 0;
23165 }
23166 41300 }
23167
23168 // Returns true if the pointer is at a string's
23169 // null terminator or a trailing space
23170 131213 bool atend(char const* str)
23171 {
23172 131213 int32_t i=0;
23173
23174
2/2
✓ Branch 0 taken 1355858 times.
✓ Branch 1 taken 131213 times.
1487071 while(str[i]==' ')
23175 1355858 i++;
23176
23177 131213 return str[i]=='\0';
23178 }
23179
23180 5173306 void putmsg()
23181 {
23182 5173306 bool oldmargin = get_bit(quest_rules, qr_OLD_STRING_EDITOR_MARGINS)!=0;
23183
2/2
✓ Branch 0 taken 5047705 times.
✓ Branch 1 taken 125601 times.
5173306 if(!msgorig) msgorig=msgstr;
23184
23185
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5173306 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5173306 if(wait_advance && linkedmsgclk < 1)
23186 linkedmsgclk = 1;
23187
2/2
✓ Branch 0 taken 5146765 times.
✓ Branch 1 taken 26541 times.
5173306 if(linkedmsgclk>0)
23188 {
23189
2/2
✓ Branch 0 taken 6740 times.
✓ Branch 1 taken 19801 times.
26541 if(linkedmsgclk==1)
23190 {
23191
5/6
✓ Branch 0 taken 6740 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6428 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 6344 times.
6740 if(do_end_str||cAbtn()||cBbtn())
23192 {
23193 396 do_end_str = false;
23194 396 linkedmsgclk = 0;
23195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 if(wait_advance)
23196 {
23197 wait_advance = false;
23198 }
23199 else
23200 {
23201 396 msgstr=MsgStrings[msgstr].nextstring;
23202
3/4
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 229 times.
✓ Branch 2 taken 167 times.
✗ Branch 3 not taken.
396 if(!msgstr && enqueued_str)
23203 {
23204 msgstr = enqueued_str;
23205 enqueued_str = 0;
23206 }
23207
2/2
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 167 times.
396 if(!msgstr)
23208 {
23209 167 msgfont=zfont;
23210
23211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
167 if(tmpscr->room!=rGRUMBLE)
23212 167 blockpath=false;
23213
23214 167 dismissmsg();
23215 167 goto disappear;
23216 }
23217
23218 229 donewmsg(msgstr);
23219 229 putprices(false);
23220 }
23221 229 }
23222 6573 }
23223 else
23224 {
23225 19801 --linkedmsgclk;
23226 }
23227 26374 }
23228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5173139 times.
5173139 if(wait_advance) return; //Waiting for buttonpress
23229
23230
9/10
✓ Branch 0 taken 5173029 times.
✓ Branch 1 taken 110 times.
✓ Branch 2 taken 124758 times.
✓ Branch 3 taken 5048271 times.
✓ Branch 4 taken 83818 times.
✓ Branch 5 taken 40940 times.
✓ Branch 6 taken 37598 times.
✓ Branch 7 taken 46220 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 37598 times.
5173139 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
23231 {
23232
2/2
✓ Branch 0 taken 87160 times.
✓ Branch 1 taken 5048271 times.
5135431 if(!msgstr)
23233 5048271 msgorig=0;
23234
23235 5135431 msg_active = false;
23236 5135431 return;
23237 }
23238
23239 37708 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
23240
23241 char s3[145];
23242 int32_t tlength;
23243
23244 // Bypass the string with the B button!
23245
4/4
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 37392 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 37192 times.
37708 if(((cBbtn())&&(get_bit(quest_rules,qr_ALLOWMSGBYPASS))) || msgspeed==0)
23246 {
23247 //finish writing out the string
23248
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 26138 times.
✓ Branch 2 taken 406 times.
✓ Branch 3 taken 25741 times.
26257 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
23249 {
23250
4/6
✓ Branch 0 taken 17002 times.
✓ Branch 1 taken 8739 times.
✓ Branch 2 taken 17002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17002 times.
✗ Branch 5 not taken.
25741 if(msgspeed && !(cBbtn() && get_bit(quest_rules,qr_ALLOWMSGBYPASS)))
23251 goto breakout; // break out if message speed was changed to non-zero
23252
4/6
✓ Branch 0 taken 25741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25741 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 236 times.
✓ Branch 5 taken 25505 times.
25741 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
23253 {
23254
1/2
✓ Branch 0 taken 25505 times.
✗ Branch 1 not taken.
25505 if(bottom_margin_clip())
23255 break;
23256
23257 25505 wrapmsgstr(s3);
23258
23259
2/2
✓ Branch 0 taken 5723 times.
✓ Branch 1 taken 19782 times.
25505 if(MsgStrings[msgstr].s[msgptr]==' ')
23260 {
23261 5723 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23262
23263
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 157 times.
5923 if(cursor_x+tlength > (msg_w-msg_margins[right])
23264
5/6
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 5523 times.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 200 times.
✓ Branch 5 taken 43 times.
5723 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23265 43 ? true : strcmp(s3," ")!=0))
23266 {
23267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
243 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23268 157 ssc_tile_hei = ssc_tile_hei_buf;
23269 157 ssc_tile_hei_buf = -1;
23270 157 cursor_y += thei + MsgStrings[msgstr].vspace;
23271
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if(bottom_margin_clip()) break;
23272 157 cursor_x=msg_margins[left];
23273 157 }
23274
23275 5723 char buf[2] = {0};
23276 5723 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23277
23278 5723 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23279
23280 5723 cursor_x+=tlength;
23281 5723 }
23282 else
23283 {
23284 19782 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23285
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 314 times.
20264 if(cursor_x+tlength > (msg_w-msg_margins[right])
23286
5/6
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 19257 times.
✓ Branch 2 taken 482 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 357 times.
✗ Branch 5 not taken.
19782 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23287 168 ? true : strcmp(s3," ")!=0))
23288 {
23289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 525 times.
525 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23290 525 ssc_tile_hei = ssc_tile_hei_buf;
23291 525 ssc_tile_hei_buf = -1;
23292 525 cursor_y += thei + MsgStrings[msgstr].vspace;
23293
1/2
✓ Branch 0 taken 525 times.
✗ Branch 1 not taken.
525 if(bottom_margin_clip()) break;
23294 525 cursor_x=msg_margins[left];
23295 525 }
23296
23297 19782 sfx(MsgStrings[msgstr].sfx);
23298
23299 19782 char buf[2] = {0};
23300 19782 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23301
23302 19782 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23303
23304 19782 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
23305 19782 cursor_x += MsgStrings[msgstr].hspace;
23306 }
23307
23308 25505 msgpos++;
23309 25505 }
23310
1/2
✓ Branch 0 taken 25741 times.
✗ Branch 1 not taken.
25741 if(do_run_menu)
23311 {
23312 if(runMenuCursor())
23313 {
23314 do_run_menu = false;
23315 }
23316 else break;
23317 }
23318
1/2
✓ Branch 0 taken 25741 times.
✗ Branch 1 not taken.
25741 if(doing_name_insert)
23319 {
23320 if(*nameptr)
23321 {
23322 if(bottom_margin_clip())
23323 break;
23324
23325 char s3[9] = {0};
23326
23327 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23328 {
23329 strcpy(s3, nameptr);
23330 }
23331 else
23332 {
23333 s3[0] = *nameptr;
23334 s3[1] = 0;
23335 }
23336
23337 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23338
23339 if(cursor_x+tlength > (msg_w-msg_margins[right])
23340 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23341 ? true : strcmp(s3," ")!=0))
23342 {
23343 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23344 ssc_tile_hei = ssc_tile_hei_buf;
23345 ssc_tile_hei_buf = -1;
23346 cursor_y += thei + MsgStrings[msgstr].vspace;
23347 if(bottom_margin_clip()) break;
23348 cursor_x=msg_margins[left];
23349 }
23350
23351 sfx(MsgStrings[msgstr].sfx);
23352
23353 char buf[2] = {0};
23354 sprintf(buf,"%c",*nameptr);
23355
23356 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23357
23358 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
23359 cursor_x += MsgStrings[msgstr].hspace;
23360 ++nameptr;
23361 continue; //don't advance the msgptr, as the next char in it was not processed!
23362 }
23363 else doing_name_insert = false;
23364 }
23365 25741 ++msgptr;
23366
1/2
✓ Branch 0 taken 25741 times.
✗ Branch 1 not taken.
25741 if(do_end_str)
23367 goto strendcheck;
23368
1/2
✓ Branch 0 taken 25741 times.
✗ Branch 1 not taken.
25741 if(wait_advance)
23369 return;
23370
2/2
✓ Branch 0 taken 25335 times.
✓ Branch 1 taken 406 times.
25741 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23371 {
23372
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 171 times.
406 if(MsgStrings[msgstr].nextstring)
23373 {
23374
1/2
✓ Branch 0 taken 171 times.
✗ Branch 1 not taken.
171 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23375 {
23376 msgstr=MsgStrings[msgstr].nextstring;
23377 msgpos=msgptr=0;
23378 msgfont=setmsgfont();
23379 }
23380 171 }
23381 406 }
23382 }
23383
23384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if (!do_run_menu)
23385 {
23386 406 msgclk = 72;
23387 406 msgpos = 10000;
23388 406 }
23389 406 }
23390 else
23391 37192 {
23392 breakout:
23393
23394
6/6
✓ Branch 0 taken 30852 times.
✓ Branch 1 taken 6340 times.
✓ Branch 2 taken 14296 times.
✓ Branch 3 taken 16556 times.
✓ Branch 4 taken 9773 times.
✓ Branch 5 taken 4523 times.
37192 if(((msgclk++)%(msgspeed+1)<msgspeed)&&((!cAbtn())||(!get_bit(quest_rules,qr_ALLOWFASTMSG))))
23395 21079 return;
23396 }
23397
23398 // Start writing the string
23399
2/2
✓ Branch 0 taken 16023 times.
✓ Branch 1 taken 496 times.
17015 if(msgptr == 0)
23400 {
23401
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 889 times.
1385 while(MsgStrings[msgstr].s[msgptr]==' ')
23402 {
23403 889 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23404
23405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
890 if(cursor_x+tlength > (msg_w-msg_margins[right])
23406
4/6
✓ Branch 0 taken 888 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
889 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23407 ? 1 : strcmp(s3," ")!=0))
23408 {
23409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23410 1 ssc_tile_hei = ssc_tile_hei_buf;
23411 1 ssc_tile_hei_buf = -1;
23412 1 cursor_y += thei + MsgStrings[msgstr].vspace;
23413
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(bottom_margin_clip()) break;
23414 1 cursor_x=msg_margins[left];
23415 1 }
23416
23417 889 cursor_x+=tlength;
23418 889 ++msgptr;
23419 889 ++msgpos;
23420
23421 // The "Continue From Previous" feature
23422
1/2
✓ Branch 0 taken 889 times.
✗ Branch 1 not taken.
889 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23423 {
23424 if(MsgStrings[msgstr].nextstring)
23425 {
23426 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23427 {
23428 msgstr=MsgStrings[msgstr].nextstring;
23429 msgpos=msgptr=0;
23430 msgfont=setmsgfont();
23431 }
23432 }
23433 }
23434 }
23435 496 }
23436
23437 reparsesinglechar:
23438 // Continue printing the string!
23439
3/4
✓ Branch 0 taken 15889 times.
✓ Branch 1 taken 630 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15889 times.
32408 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
23440 {
23441
4/6
✓ Branch 0 taken 15889 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15889 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 15795 times.
15889 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
23442 {
23443 15795 wrapmsgstr(s3);
23444
23445 15795 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23446
23447
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 169 times.
15984 if(cursor_x+tlength > (msg_w-msg_margins[right])
23448
6/6
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 15602 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 4 times.
15795 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23449 20 ? true : strcmp(s3," ")!=0))
23450 {
23451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23452 189 ssc_tile_hei = ssc_tile_hei_buf;
23453 189 ssc_tile_hei_buf = -1;
23454 189 cursor_y += thei + MsgStrings[msgstr].vspace;
23455
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(bottom_margin_clip()) goto strendcheck;
23456 189 cursor_x=msg_margins[left];
23457 //if(space) s3[0]=0;
23458 189 }
23459
23460 15795 sfx(MsgStrings[msgstr].sfx);
23461
23462 15795 char buf[2] = {0};
23463 15795 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23464
23465 15795 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23466
23467 15795 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
23468 15795 cursor_x += MsgStrings[msgstr].hspace;
23469 15795 msgpos++;
23470 15795 }
23471
1/2
✓ Branch 0 taken 15889 times.
✗ Branch 1 not taken.
15889 if(do_end_str)
23472 goto strendcheck;
23473
1/2
✓ Branch 0 taken 15889 times.
✗ Branch 1 not taken.
15889 if(wait_advance)
23474 {
23475 ++msgptr;
23476 return;
23477 }
23478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15889 times.
15889 else if(do_run_menu)
23479 {
23480 if(runMenuCursor())
23481 {
23482 do_run_menu = false;
23483 ++msgptr;
23484 goto reparsesinglechar;
23485 }
23486 }
23487
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15889 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15889 else if(doing_name_insert && *nameptr)
23488 {
23489 char s3[9] = {0};
23490
23491 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23492 {
23493 strcpy(s3, nameptr);
23494 }
23495 else
23496 {
23497 s3[0] = *nameptr;
23498 s3[1] = 0;
23499 }
23500
23501 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23502
23503 if(cursor_x+tlength > (msg_w-msg_margins[right])
23504 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23505 ? true : strcmp(s3," ")!=0))
23506 {
23507 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23508 ssc_tile_hei = ssc_tile_hei_buf;
23509 ssc_tile_hei_buf = -1;
23510 cursor_y += thei + MsgStrings[msgstr].vspace;
23511 if(bottom_margin_clip()) goto strendcheck;
23512 cursor_x=msg_margins[left];
23513 }
23514
23515 sfx(MsgStrings[msgstr].sfx);
23516
23517 char buf[2] = {0};
23518 sprintf(buf,"%c",*nameptr);
23519
23520 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23521
23522 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
23523 cursor_x += MsgStrings[msgstr].hspace;
23524 ++nameptr;
23525 }
23526 else
23527 {
23528 15889 doing_name_insert = false;
23529 15889 msgptr++;
23530
23531
2/2
✓ Branch 0 taken 15480 times.
✓ Branch 1 taken 409 times.
15889 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23532 {
23533
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 59 times.
409 if(MsgStrings[msgstr].nextstring)
23534 {
23535
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23536 {
23537 msgstr=MsgStrings[msgstr].nextstring;
23538 msgpos=msgptr=0;
23539 msgfont=setmsgfont();
23540 }
23541 59 }
23542 409 }
23543
23544
2/2
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 813 times.
19056 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
23545
2/2
✓ Branch 0 taken 15861 times.
✓ Branch 1 taken 28 times.
15889 && (MsgStrings[msgstr].s[msgptr]==' ')
23546
2/2
✓ Branch 0 taken 3167 times.
✓ Branch 1 taken 12694 times.
15861 && (MsgStrings[msgstr].s[msgptr+1]==' '))
23547 {
23548
2/2
✓ Branch 0 taken 813 times.
✓ Branch 1 taken 30327 times.
31140 while(MsgStrings[msgstr].s[msgptr]==' ')
23549 {
23550 30327 msgspace = true;
23551 30327 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23552
23553
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1309 times.
31659 if(cursor_x+tlength > (msg_w-msg_margins[right])
23554
4/6
✓ Branch 0 taken 1332 times.
✓ Branch 1 taken 28995 times.
✓ Branch 2 taken 1332 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1309 times.
✗ Branch 5 not taken.
30327 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23555 23 ? true : strcmp(s3," ")!=0))
23556 {
23557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1332 times.
1332 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23558 1332 ssc_tile_hei = ssc_tile_hei_buf;
23559 1332 ssc_tile_hei_buf = -1;
23560 1332 cursor_y += thei + MsgStrings[msgstr].vspace;
23561
1/2
✓ Branch 0 taken 1332 times.
✗ Branch 1 not taken.
1332 if(bottom_margin_clip()) break;
23562 1332 cursor_x=msg_margins[left];
23563 1332 }
23564
23565 30327 cursor_x+=tlength;
23566 30327 ++msgpos;
23567 30327 ++msgptr;
23568
23569
2/2
✓ Branch 0 taken 2213 times.
✓ Branch 1 taken 28114 times.
30327 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23570 {
23571
2/2
✓ Branch 0 taken 24063 times.
✓ Branch 1 taken 4051 times.
28114 if(MsgStrings[msgstr].nextstring)
23572 {
23573
1/2
✓ Branch 0 taken 4051 times.
✗ Branch 1 not taken.
4051 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23574 {
23575 msgstr=MsgStrings[msgstr].nextstring;
23576 msgpos=msgptr=0;
23577 msgfont=setmsgfont();
23578 }
23579 4051 }
23580 28114 }
23581 }
23582 813 }
23583 }
23584 15889 }
23585 strendcheck:
23586 // Done printing the string
23587
10/14
✓ Branch 0 taken 16519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16519 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16113 times.
✓ Branch 7 taken 406 times.
✓ Branch 8 taken 15710 times.
✓ Branch 9 taken 403 times.
✓ Branch 10 taken 15710 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 15704 times.
✓ Branch 13 taken 815 times.
16519 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
23588 {
23589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 815 times.
815 if(!do_end_str)
23590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 815 times.
815 while(parsemsgcode()); // Finish remaining control codes
23591
23592 // Go to next string, or make it disappear by going to string 0.
23593
5/6
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 230 times.
✓ Branch 2 taken 418 times.
✓ Branch 3 taken 167 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 418 times.
815 if(MsgStrings[msgstr].nextstring!=0 || get_bit(quest_rules,qr_MSGDISAPPEAR) || enqueued_str)
23594 {
23595 397 linkedmsgclk=do_end_str?1:51;
23596 397 }
23597
23598
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 230 times.
815 if(MsgStrings[msgstr].nextstring==0)
23599 {
23600
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 418 times.
585 if(!get_bit(quest_rules,qr_MSGDISAPPEAR))
23601 418 {
23602 disappear:
23603 585 msg_active = false;
23604 585 Hero.finishedmsg();
23605 585 }
23606
23607
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 12 times.
752 if(repaircharge)
23608 {
23609 // if (get_bit(quest_rules,qr_REPAIRFIX)) {
23610 // fixed_door=true;
23611 // }
23612 12 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
23613 12 repaircharge = 0;
23614 12 }
23615
23616
2/2
✓ Branch 0 taken 751 times.
✓ Branch 1 taken 1 times.
752 if(adjustmagic)
23617 {
23618
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(get_bit(quest_rules,qr_OLD_HALF_MAGIC))
23619 {
23620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(game->get_magicdrainrate())
23621 1 game->set_magicdrainrate(1);
23622 1 }
23623 else if(game->get_magicdrainrate() > 1)
23624 {
23625 game->set_magicdrainrate(game->get_magicdrainrate()/2);
23626 }
23627 1 adjustmagic = false;
23628 1 sfx(WAV_SCALE);
23629
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
23630 1 }
23631
23632
2/2
✓ Branch 0 taken 751 times.
✓ Branch 1 taken 1 times.
752 if(learnslash)
23633 {
23634 1 game->set_canslash(1);
23635 1 learnslash = false;
23636 1 sfx(WAV_SCALE);
23637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
23638 1 }
23639 752 }
23640 982 }
23641 5173196 }
23642
23643 6556 int32_t message_more_y()
23644 {
23645 //Is the flag ticked, do we really want a message more y larger than 160?
23646
5/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 6542 times.
✓ Branch 2 taken 6556 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6542 times.
✓ Branch 5 taken 14 times.
6556 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
23647 6556 msgy+=playing_field_offset;
23648 6556 return msgy;
23649 }
23650
23651 /*** Collision detection & handling ***/
23652
23653 5150995 void clear_script_one_frame_conditions()
23654 {
23655
2/2
✓ Branch 0 taken 16101087 times.
✓ Branch 1 taken 5150995 times.
21252082 for(int32_t j=0; j<guys.Count(); j++)
23656 {
23657 16101087 enemy *e = (enemy*)guys.spr(j);
23658
2/2
✓ Branch 0 taken 257617392 times.
✓ Branch 1 taken 16101087 times.
273718479 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
23659 16101087 }
23660 5150995 }
23661
23662 5150916 void check_collisions()
23663 {
23664 5150916 bool temp_hit = false;
23665
2/2
✓ Branch 0 taken 2324602 times.
✓ Branch 1 taken 5150916 times.
7475518 for(int32_t i=0; i<Lwpns.Count(); i++)
23666 {
23667 2324602 weapon *w = (weapon*)Lwpns.spr(i);
23668
23669
8/8
✓ Branch 0 taken 2013812 times.
✓ Branch 1 taken 310790 times.
✓ Branch 2 taken 1695816 times.
✓ Branch 3 taken 317996 times.
✓ Branch 4 taken 1693038 times.
✓ Branch 5 taken 2778 times.
✓ Branch 6 taken 10727 times.
✓ Branch 7 taken 1682311 times.
2324602 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
23670 {
23671
2/2
✓ Branch 0 taken 1673455 times.
✓ Branch 1 taken 5971119 times.
7644574 for(int32_t j=0; j<guys.Count(); j++)
23672 {
23673 5971119 enemy *e = (enemy*)guys.spr(j);
23674
2/2
✓ Branch 0 taken 54375 times.
✓ Branch 1 taken 5916744 times.
5971119 if ( !temp_hit ) e->hitby[HIT_BY_LWEAPON] = 0;
23675
23676
2/2
✓ Branch 0 taken 5861423 times.
✓ Branch 1 taken 109696 times.
5971119 if(e->hit(w)) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
23677 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
23678 {
23679 // !(e->stunclk)
23680 109696 int32_t h = e->takehit(w);
23681
2/2
✓ Branch 0 taken 91839 times.
✓ Branch 1 taken 17857 times.
109696 if (h == -1)
23682 {
23683 17857 e->hitby[HIT_BY_LWEAPON] = i+1; temp_hit = true;
23684 17857 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
23685 //e->hitby[HIT_BY_LWEAPON_FAMILY] = itemsbuf[w->parentid].family; //that would be the itemclass, not the weapon type!
23686 17857 e->hitby[HIT_BY_LWEAPON_FAMILY] = w->id;
23687 //al_trace("npc->HitBy[] Parent Item is: %d /n", w->parentitem);
23688 //al_trace("npc->HitBy[] Parent ID is: %d /n", w->parentid);
23689 17857 e->hitby[HIT_BY_LWEAPON_LITERAL_ID] = w->parentitem;
23690
23691 17857 }
23692 //we may need to handle this in special cases. -Z
23693
23694 //if h == stun or ignore
23695
23696 //if e->stun > DEFAULT_STUN -1 || !e->stun
23697 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
23698 ///! how about: if w->dead != bounce !
23699
23700 // NOT FOR PUBLIC RELEASE
23701 /*if(h==3) //Mirror shield
23702 {
23703 if (w->id==ewFireball || w->id==wRefFireball)
23704 {
23705 w->id=wRefFireball;
23706 switch(e->dir)
23707 {
23708 case up: e->angle += (PI - e->angle) * 2.0; break;
23709 case down: e->angle = -e->angle; break;
23710 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
23711 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
23712 // TODO: the following. -L.
23713 case l_up: break;
23714 case r_up: break;
23715 case l_down: break;
23716 case r_down: break;
23717 }
23718 }
23719 else
23720 {
23721 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
23722 w->dir ^= 1;
23723 if(w->dir&2)
23724 w->flip ^= 1;
23725 else
23726 w->flip ^= 2;
23727 }
23728 w->ignoreHero=false;
23729 }
23730 else*/
23731
2/2
✓ Branch 0 taken 86025 times.
✓ Branch 1 taken 23671 times.
109696 if(h)
23732 {
23733
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23671 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23671 if(e->switch_hooked && w->family_class == itype_switchhook)
23734 w->onhit(false, e, -1);
23735 23671 else w->onhit(false, e, h);
23736 23671 }
23737
23738
2/2
✓ Branch 0 taken 107512 times.
✓ Branch 1 taken 2184 times.
109696 if(h==2)
23739 {
23740 2184 break;
23741 }
23742 107512 }
23743
23744
2/2
✓ Branch 0 taken 5962263 times.
✓ Branch 1 taken 6672 times.
5968935 if(w->Dead())
23745 {
23746 6672 break;
23747 }
23748 5962263 }
23749
23750 // Item flags added in 2.55:
23751 // BRang/HShot/Arrows ITEM_FLAG4 is "Pick up anything" (port of qr_BRANGPICKUP)
23752 // BRang/HShot ITEM_FLAG5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
23753 // Arrows ITEM_FLAG2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
23754 // -V
23755
6/6
✓ Branch 0 taken 1431412 times.
✓ Branch 1 taken 250899 times.
✓ Branch 2 taken 1429611 times.
✓ Branch 3 taken 1801 times.
✓ Branch 4 taken 9758 times.
✓ Branch 5 taken 1419853 times.
1682311 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
23756 {
23757 262458 int32_t itype, pitem = w->parentitem;
23758
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 250899 times.
✓ Branch 2 taken 9758 times.
✓ Branch 3 taken 1801 times.
262458 switch(w->id)
23759 {
23760 250899 case wBrang: itype = itype_brang; break;
23761 9758 case wArrow: itype = itype_arrow; break;
23762 case wHookshot:
23763 1801 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
23764 1801 break;
23765 }
23766
2/2
✓ Branch 0 taken 261293 times.
✓ Branch 1 taken 1165 times.
262458 if(pitem < 0) pitem = current_item_id(itype);
23767
5/6
✓ Branch 0 taken 1801 times.
✓ Branch 1 taken 260657 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 1701 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
262458 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & ITEM_FLAG9))
23768 { //Swap with item
23769 for(int32_t j=0; j<items.Count(); j++)
23770 {
23771 if(items.spr(j)->hit(w))
23772 {
23773 item *theItem = ((item*)items.spr(j));
23774 bool priced = theItem->PriceIndex >-1;
23775 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23776 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23777 || (((itemsbuf[w->parentitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
23778 {
23779 if(!Hero.switchhookclk)
23780 {
23781 hooked_combopos = -1;
23782 hooked_layerbits = 0;
23783 switching_object = theItem;
23784 theItem->switch_hooked = true;
23785 w->misc = 2;
23786 w->step = 0;
23787 theItem->clk2=256;
23788 Hero.doSwitchHook(game->get_switchhookstyle());
23789 if(QMisc.miscsfx[sfxSWITCHED])
23790 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
23791 }
23792 }
23793 }
23794 }
23795 }
23796
6/6
✓ Branch 0 taken 9758 times.
✓ Branch 1 taken 252700 times.
✓ Branch 2 taken 245304 times.
✓ Branch 3 taken 235546 times.
✓ Branch 4 taken 252700 times.
✓ Branch 5 taken 235546 times.
262458 else if((w->id==wArrow&&itemsbuf[pitem].flags & ITEM_FLAG2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & ITEM_FLAG5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
23797 {
23798
2/2
✓ Branch 0 taken 58777 times.
✓ Branch 1 taken 245304 times.
304081 for(int32_t j=0; j<items.Count(); j++)
23799 {
23800
2/2
✓ Branch 0 taken 55361 times.
✓ Branch 1 taken 3416 times.
58777 if(items.spr(j)->hit(w))
23801 {
23802 3416 item *theItem = ((item*)items.spr(j));
23803 3416 bool priced = theItem->PriceIndex >-1;
23804
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 3402 times.
3416 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23805
5/8
✓ Branch 0 taken 3416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3416 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2798 times.
✓ Branch 5 taken 618 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1539 times.
4955 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23806
4/6
✓ Branch 0 taken 2157 times.
✓ Branch 1 taken 1539 times.
✓ Branch 2 taken 2157 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2157 times.
3416 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey))&& !priced)))
23807 {
23808
1/2
✓ Branch 0 taken 1259 times.
✗ Branch 1 not taken.
4337 if(itemsbuf[theItem->id].collect_script)
23809 {
23810 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
23811 }
23812
23813 1259 Hero.checkitems(j);
23814 1259 }
23815 3416 }
23816 58777 }
23817 245304 }
23818
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 15966 times.
488246 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
23819 {
23820
2/2
✓ Branch 0 taken 3334 times.
✓ Branch 1 taken 15966 times.
19300 for(int32_t j=0; j<items.Count(); j++)
23821 {
23822
2/2
✓ Branch 0 taken 2399 times.
✓ Branch 1 taken 935 times.
3334 if(items.spr(j)->hit(w))
23823 {
23824 935 item *theItem = ((item*)items.spr(j));
23825 935 bool priced = theItem->PriceIndex >-1;
23826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 935 times.
935 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23827
4/6
✓ Branch 0 taken 935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 935 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 895 times.
✓ Branch 5 taken 40 times.
935 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23828
5/10
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 376 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 376 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
935 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
23829 {
23830 559 int32_t pickup = theItem->pickup;
23831 559 int32_t id2 = theItem->id;
23832 559 int32_t pstr = theItem->pstring;
23833 559 int32_t pstr_flags = theItem->pickup_string_flags;
23834
23835 559 std::vector<int32_t> &ev = FFCore.eventData;
23836 559 ev.clear();
23837 559 ev.push_back(id2*10000);
23838 559 ev.push_back(pickup*10000);
23839 559 ev.push_back(pstr*10000);
23840 559 ev.push_back(pstr_flags*10000);
23841 559 ev.push_back(0);
23842 559 ev.push_back(theItem->getUID());
23843 559 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
23844 559 ev.push_back(w->getUID());
23845
23846 559 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
23847 559 bool nullify = ev[4] != 0;
23848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(nullify) continue;
23849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(w->id == wBrang)
23850 {
23851 559 w->onhit(false);
23852 559 }
23853
23854
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 37 times.
559 if(w->dragging==-1)
23855 {
23856 37 w->dead=1;
23857 37 theItem->clk2=256;
23858 37 w->dragging=j;
23859 37 theItem->is_dragged = true;
23860 37 }
23861 559 }
23862 935 }
23863 3334 }
23864 15966 }
23865 262458 }
23866 1682311 }
23867 2324602 }
23868 5150916 }
23869
23870 5150995 void dragging_item()
23871 {
23872
2/2
✓ Branch 0 taken 2363020 times.
✓ Branch 1 taken 5150995 times.
7514015 for(int32_t i=0; i<Lwpns.Count(); i++)
23873 {
23874 2363020 weapon *w = (weapon*)Lwpns.spr(i);
23875
23876
4/4
✓ Branch 0 taken 2106846 times.
✓ Branch 1 taken 256174 times.
✓ Branch 2 taken 2346713 times.
✓ Branch 3 taken 16307 times.
2363020 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & ITEM_FLAG5)//ITEM_FLAG5 is a port for qr_Z3BRANG_HSHOT
23877 {
23878
3/4
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 15756 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 551 times.
16307 if(w->dragging>=0 && w->dragging<items.Count())
23879 {
23880 551 item* dragItem = (item*)items.spr(w->dragging);
23881 551 dragItem->x=w->x;
23882 551 dragItem->y=w->y;
23883
23884 // Drag the Fairy enemy as well as the Fairy item
23885 551 int32_t id = dragItem->id;
23886
23887
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 551 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
551 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
23888 {
23889 movefairynew2(w->x,w->y,*dragItem);
23890 }
23891 551 }
23892 16307 }
23893 2363020 }
23894 5150995 }
23895
23896 20 int32_t more_carried_items()
23897 {
23898 20 int32_t hasmorecarries = 0;
23899
23900
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 20 times.
42 for(int32_t i=0; i<items.Count(); i++)
23901 {
23902
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 20 times.
22 if(((item*)items.spr(i))->pickup & ipENEMY)
23903 {
23904 20 hasmorecarries++;
23905 20 }
23906 22 }
23907
23908 20 return hasmorecarries;
23909 }
23910
23911 // messy code to do the enemy-carrying-the-item thing
23912 5150995 void roaming_item()
23913 {
23914
4/4
✓ Branch 0 taken 9588 times.
✓ Branch 1 taken 5141407 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 9566 times.
5150995 if(!(hasitem&(4|2)) || !loaded_enemies)
23915 5141429 return;
23916
23917 // All enemies already dead upon entering a room?
23918
1/2
✓ Branch 0 taken 9566 times.
✗ Branch 1 not taken.
9566 if(guys.Count()==0)
23919 {
23920 return;
23921 }
23922
23923 // Lost track of the carrier?
23924
4/6
✓ Branch 0 taken 9566 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9566 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9561 times.
✓ Branch 5 taken 5 times.
9566 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
23925 9566 !((enemy*)guys.spr(guycarryingitem))->itemguy)
23926 {
23927 5 guycarryingitem=-1;
23928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 for(int32_t j=0; j<guys.Count(); j++)
23929 {
23930
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5 times.
19 if(((enemy*)guys.spr(j))->itemguy)
23931 {
23932 5 guycarryingitem=j;
23933 5 break;
23934 }
23935 14 }
23936 5 }
23937
23938
2/2
✓ Branch 0 taken 9545 times.
✓ Branch 1 taken 21 times.
9566 if(hasitem&4)
23939 {
23940 21 guycarryingitem = -1;
23941
23942
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 21 times.
189 for(int32_t i=0; i<guys.Count(); i++)
23943 {
23944
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 21 times.
168 if(((enemy*)guys.spr(i))->itemguy)
23945 {
23946 21 guycarryingitem = i;
23947 21 }
23948 168 }
23949
23950
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(guycarryingitem == -1) //This happens when "default enemies" such as
23951 {
23952 return; //eSHOOTFBALL are alive but enemies from the list
23953 } //are not. Defer to HeroClass::checkspecial().
23954
23955 21 int32_t Item=tmpscr->item;
23956
23957 21 hasitem &= ~4;
23958
23959
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
23960 {
23961 39 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
23962
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 18 times.
21 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
23963 );
23964 21 hasitem |= 2;
23965 21 }
23966 else
23967 {
23968 return;
23969 }
23970 21 }
23971
23972
2/2
✓ Branch 0 taken 10080 times.
✓ Branch 1 taken 9566 times.
19646 for(int32_t i=0; i<items.Count(); i++)
23973 {
23974
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 9566 times.
10080 if(((item*)items.spr(i))->pickup&ipENEMY)
23975 {
23976
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 7221 times.
9566 if(get_bit(quest_rules,qr_HIDECARRIEDITEMS))
23977 {
23978 7221 items.spr(i)->x = -128; // Awfully inelegant, innit?
23979 7221 items.spr(i)->y = -128;
23980 7221 }
23981
2/4
✓ Branch 0 taken 2345 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2345 times.
2345 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
23982 {
23983
1/2
✓ Branch 0 taken 2345 times.
✗ Branch 1 not taken.
2345 if (!get_bit(quest_rules, qr_BROKEN_ITEM_CARRYING))
23984 {
23985 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
23986 {
23987 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hxsz/2)-8;
23988 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hysz/2)-10;
23989 }
23990 else
23991 {
23992 if(guys.spr(guycarryingitem)->extend >= 3)
23993 {
23994 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
23995 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
23996 }
23997 else
23998 {
23999 items.spr(i)->x = guys.spr(guycarryingitem)->x;
24000 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
24001 }
24002 }
24003 items.spr(i)->z = guys.spr(guycarryingitem)->z;
24004 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
24005 }
24006 else
24007 {
24008 2345 items.spr(i)->x = guys.spr(guycarryingitem)->x;
24009 2345 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
24010 2345 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
24011 }
24012 2345 }
24013 9566 }
24014 10080 }
24015 5150995 }
24016
24017 bool enemy::IsBigAnim()
24018 {
24019 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
24020 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
24021 || anim == a4FRM8DIRB);
24022 }
24023
24024 const char *old_guy_string[OLDMAXGUYS] =
24025 {
24026 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
24027 // 020
24028 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
24029 // 025
24030 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
24031 // 030
24032 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
24033 // 035
24034 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
24035 // 040
24036 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
24037 // 045
24038 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
24039 // 050
24040 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
24041 // 055
24042 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
24043 // 060
24044 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
24045 // 065
24046 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
24047 // 070
24048 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
24049 // 075
24050 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
24051 // 080
24052 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
24053 // 085
24054 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
24055 // 090
24056 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
24057 // 095
24058 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
24059 // 100
24060 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
24061 // 105
24062 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
24063 // 110
24064 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
24065 // 115
24066 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
24067 // 120
24068 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
24069 // 125
24070 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
24071 // 130
24072 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
24073 // 135
24074 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
24075 // 140
24076 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
24077 // 145
24078 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
24079 // 150
24080 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
24081 // 155
24082 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
24083 // 160
24084 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
24085 // 165
24086 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
24087 // 170
24088 "Pols Voice (Magic) ", "Pols Voice (Whistle) ", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
24089 // 175
24090 "Grappler Bug (HP) ", "Grappler Bug (MP) "
24091 };
24092
24093 /*** end of guys.cc ***/
24094
24095